Class Crdb

java.lang.Object
com.cockroachlabs.crdb.Crdb

public final class Crdb extends Object
The one-stop entry point for the CockroachDB pure-Java library.

Two things you reach for constantly:

  • enhance(Object) — wrap an annotated object so retry, circuit breaking, and context "just happen"; the anomaly try/catch disappears from your code.
  • tx(DataSource, ConnectionCallback) — the always-available functional core: a SERIALIZABLE, auto-retrying transaction.

The storage, vcluster, and aegis methods expose the Cockroach Continuum surface (Plenum, vCluster, Aegis); storage/aegis providers are discovered from the continuum module via ServiceLoader. The agent/MCP surface lives in the agent module (CrdbAgent). See docs/CONTINUUM_PLAN.md.

  • Method Details

    • enhance

      public static <T> T enhance(T target)
      Return an enhanced view of target whose annotated methods gain retry / circuit-breaking / context behavior. See CrdbProxyFactory.enhance(Object) for the interface-vs-class caveat.
    • enhance

      public static <T> T enhance(T target, CrdbConfig config)
      As enhance(Object), using a specific CrdbConfig.
    • tx

      public static <T> T tx(DataSource ds, ConnectionCallback<T> work)
      Run work in a SERIALIZABLE transaction with automatic retry on serialization conflicts. This is the functional core that never needs a proxy or annotations.
    • template

      public static TransactionTemplate template(DataSource ds)
      A reusable TransactionTemplate bound to ds.
    • storage

      public static StorageInsights storage(DataSource ds)
      Cockroach Plenum storage insights (read-only usage signals). The provider is discovered from the continuum module via ServiceLoader.
      Throws:
      IllegalStateException - if the continuum module is not on the classpath
    • vcluster

      public static VirtualClusterScope vcluster(String name)
      Cockroach vCluster handle: a context-scoped executor that tags work with a vCluster name and (optionally) a workload priority/QoS.
    • aegis

      public static AegisClient aegis(AegisConfig config)
      Cockroach Aegis client (autonomous-ops findings/recommendations + exhaust). The provider is discovered from the continuum module via ServiceLoader; a disabled/endpoint-less config selects the simulated in-memory backend.
      Throws:
      IllegalStateException - if the continuum module is not on the classpath
    • agent

      public static Object agent()
      Agent / MCP surface. Use CrdbAgent.from(...) in the agent module to build the tool surface.
      Throws:
      UnsupportedOperationException - always; this is a signpost to the agent module's CrdbAgent entry point