Class ClientRequestContext.ContextScope

java.lang.Object
com.loomcache.client.context.ClientRequestContext.ContextScope
Enclosing class:
ClientRequestContext

public static class ClientRequestContext.ContextScope extends Object
Fluent builder for constructing scoped context with specific values.
Since:
1.0
  • Constructor Details

    • ContextScope

      public ContextScope()
  • Method Details

    • requestId

      public ClientRequestContext.ContextScope requestId(@Nullable String value)
      Set the request ID for this scope.
      Parameters:
      value - the request ID (may be null)
      Returns:
      this scope for chaining
    • operationName

      public ClientRequestContext.ContextScope operationName(@Nullable String value)
      Set the operation name for this scope.
      Parameters:
      value - the operation name (may be null)
      Returns:
      this scope for chaining
    • mapName

      public ClientRequestContext.ContextScope mapName(@Nullable String value)
      Set the map name for this scope.
      Parameters:
      value - the map name (may be null)
      Returns:
      this scope for chaining
    • startTimestamp

      public ClientRequestContext.ContextScope startTimestamp(@Nullable Long value)
      Set the start timestamp for this scope.
      Parameters:
      value - the start timestamp in nanoseconds (may be null)
      Returns:
      this scope for chaining
    • run

      public void run(Runnable runnable)
      Execute a runnable within this scoped context. Context values are set before execution and cleaned up afterward.
      Parameters:
      runnable - the code to execute with context bound
    • call

      public <T> @Nullable T call(Supplier<@Nullable T> supplier)
      Execute a supplier within this scoped context and return its result. Context values are set before execution and cleaned up afterward.
      Parameters:
      supplier - the code to execute with context bound
      Returns:
      the result of the supplier