Interface RequestContextResolver

All Known Implementing Classes:
ThreadLocalRequestContextResolver

public interface RequestContextResolver
The holder for the current request context that is bound to instrumented threads. Allowing lookup of the current request if it is present. The Default implementation uses ThreadLocal. If you are able, you should provide an implementation using ScopedValues.
  • Method Details

    • callWith

      <T> T callWith(ServerContext ctx, Callable<T> callable) throws Exception
      Wraps the execution of the given callable in request context processing.
      Type Parameters:
      T - The return type of the callable
      Parameters:
      ctx - The request context
      callable - The callable
      Returns:
      The return value of the callable
      Throws:
      Exception - if the callable throws an exception
    • supplyWith

      <T> T supplyWith(ServerContext ctx, Supplier<T> supplier)
      Wraps the execution of the given supplier in request context processing.
      Type Parameters:
      T - The return type of the supplier
      Parameters:
      ctx - The request context
      supplier - The supplier
      Returns:
      The return value of the supplier
    • runWith

      void runWith(ServerContext ctx, Runnable runnable)
      Wraps the execution of the given runnable in request context processing.
      Parameters:
      ctx - The request context
      runnable - The runnable
    • currentRequest

      Optional<ServerContext> currentRequest()
      Retrieve the current server context.
      Returns:
      The request context if it is present