@Produces
    static ListenableFuture<List<Long>> fetchFromFakeDb(ServiceRequestContext context,
                                                        ListeningScheduledExecutorService blockingExecutor) {
        // The context is mounted in a thread-local, meaning it is available to all logic such as tracing.
        checkState(ServiceRequestContext.current() == context);
        checkState(context.eventLoop().inEventLoop());
        // This logic mimics using a blocking method, which would usually be something like a MySQL database
        // query using JDBC.
        // Always run blocking logic on the blocking task executor. By using
        // ServiceRequestContext.blockingTaskExecutor (indirectly via the ListeningScheduledExecutorService
        // wrapper we defined in MainModule), you also ensure the context is mounted inside the logic (e.g.,
        // your DB call will be traced!).
        return blockingExecutor.submit(() -> {
            // The context is mounted in a thread-local, meaning it is available to all logic such as tracing.
            checkState(ServiceRequestContext.current() == context);
            checkState(!context.eventLoop().inEventLoop());

            Uninterruptibles.sleepUninterruptibly(Duration.ofMillis(50));
            return ImmutableList.of(23L, -23L);
        });
    }
The Dagger {@link ProducerModule} that models the asynchronous steps of executing a request. Dagger's
annotation compiler automatically generates code to connect the return value of methods with parameters of
other ones, even when the return value is a {@link ListenableFuture} that completes asynchronously. Because
we defined a {@literal @}{@link Production} {@link Executor} in {@link MainModule}, all methods will be
executed with the {@link ServiceRequestContext} of the request mounted in the thread-local to support usage
like distributed tracing and logging. An extra bonus is that methods with no common input parameters will
be run in parallel (here, fetchFromFakeDb and aggregateRequest are executed in parallel).
examples/context-propagation/dagger/src/main/java/example/armeria/contextpropagation/dagger/MainGraph.java