Skip to content

4.0.0

Latest
Compare
Choose a tag to compare
@bbakerman bbakerman released this 07 Apr 01:32
· 2 commits to master since this release
5865f0e

Instrumentation support of DataLoaders

A new org.dataloader.instrumentation.DataLoaderInstrumentation has been added that is a callback to allow you to know when certain DataLoader actions start and when they finish.

        DataLoaderInstrumentation timingInstrumentation = new DataLoaderInstrumentation() {
            @Override
            public DataLoaderInstrumentationContext<DispatchResult<?>> beginDispatch(DataLoader<?, ?> dataLoader) {
                long then = System.currentTimeMillis();
                return DataLoaderInstrumentationHelper.whenCompleted((result, err) -> {
                    long ms = System.currentTimeMillis() - then;
                    System.out.println(format("dispatch time: %d ms", ms));
                });
            }

            @Override
            public DataLoaderInstrumentationContext<List<?>> beginBatchLoader(DataLoader<?, ?> dataLoader, List<?> keys, BatchLoaderEnvironment environment) {
                long then = System.currentTimeMillis();
                return DataLoaderInstrumentationHelper.whenCompleted((result, err) -> {
                    long ms = System.currentTimeMillis() - then;
                    System.out.println(format("batch loader time: %d ms", ms));
                });
            }
        };
        DataLoaderOptions options = DataLoaderOptions.newOptions().setInstrumentation(timingInstrumentation);
        DataLoader<String, User> userDataLoader = DataLoaderFactory.newDataLoader(userBatchLoader, options);

Immutable classes

Some of the key classes like org.dataloader.DataLoaderOptions have been made immutable so as to provide more surety in how they get used and transformed. This is technically a breaking change if you code relied on the old mutability, however on balance we think this is a better code position to be in.

What's Changed

New Contributors

Full Changelog: v3.4.0...v4.0.0