Class VirtualClusterScope

java.lang.Object
com.cockroachlabs.crdb.vcluster.VirtualClusterScope

public final class VirtualClusterScope extends Object
A context-scoped executor for a Cockroach vCluster. Binds the vCluster (and optional workload priority) into CrdbContext for the duration of the work, so any Crdb.tx(DataSource, ConnectionCallback) run inside tags the session (SET application_name + workload QoS) at transaction start.

Scope (v1): this performs workload tagging and QoS assignment. Routing a workload to a different vCluster endpoint is platform-dependent and is intentionally not faked here — that is future work.

  • Constructor Details

    • VirtualClusterScope

      public VirtualClusterScope(String name)
  • Method Details

    • workload

      public VirtualClusterScope workload(Workload.Priority priority)
      Return a scope that also tags the workload priority/QoS.
    • name

      public String name()
      The vCluster name.
    • priority

      public Optional<Workload.Priority> priority()
      The workload priority, if set.
    • call

      public <T> T call(Callable<T> body)
      Run body with this vCluster context bound.
    • run

      public void run(Runnable body)
      Run body with this vCluster context bound.
    • tx

      public <T> T tx(DataSource ds, ConnectionCallback<T> work)
      Run a SERIALIZABLE, auto-retrying transaction with this vCluster context bound; the transaction is tagged with application_name and the mapped workload QoS at start.