Class CrdbContext

java.lang.Object
com.cockroachlabs.crdb.context.CrdbContext

public final class CrdbContext extends Object
Access point for the current CrdbContextValues, bound via ScopedValue so it is safe under virtual threads and structured concurrency.
  • Method Details

    • with

      public static <T> T with(CrdbContextValues values, Callable<T> body)
      Run body with values merged onto any currently-bound context. Nested calls refine, they do not clobber, the parent scope.
      Returns:
      the value produced by body
    • current

      public static Optional<CrdbContextValues> current()
      The full context bound to the current scope, if any.
    • region

      public static Optional<String> region()
      The region bound to the current scope, if any.
    • virtualCluster

      public static Optional<String> virtualCluster()
      The virtual cluster bound to the current scope, if any.
    • workload

      public static Optional<Workload.Priority> workload()
      The workload priority bound to the current scope, if any.
    • followerReadStaleness

      public static Optional<String> followerReadStaleness()
      The follower-read staleness expression bound to the current scope, if any.