Open-Source Wikis

/

CockroachDB

/

Packages

/

roachpb

cockroachdb/cockroach

roachpb

pkg/roachpb/ defines the core CockroachDB wire-protocol types. It is one of the most widely imported packages in the tree.

What's in it

  • data.protoValue, Span, RangeDescriptor, ReplicaDescriptor, NodeDescriptor, StoreDescriptor, Lease, SpanConfig, Transaction, Intent, Lock, …
  • metadata.proto — high-level identifiers (NodeID, StoreID, RangeID, TenantID).
  • errors.proto — top-level Error envelope. The wire-encoded kvpb.Error references this.
  • internal_raft.proto — small Raft-related shared types.
  • mvcc.proto — types shared between MVCC and KV.
  • tracing.proto — trace info wrapper.
  • gossip.proto — gossip-keyed types.
  • Hand-written Go: data.go and tenant.go carry helpers and methods on the proto-generated types.

Why it's its own package

roachpb predates the split between pkg/kv/kvpb/ (the actual BatchRequest/BatchResponse) and pkg/roachpb/ (the data types). Many older callers still reach for roachpb for descriptors and timestamps. New code should prefer the more specific package (kvpb for requests, roachpb for data types and identifiers).

Key types

Type Used by
roachpb.Span every layer; a [start, end) byte-key range
roachpb.Key every layer; a single byte-key
roachpb.RangeDescriptor KV server, range cache, gossip
roachpb.Lease KV server, leases, raft
roachpb.Transaction KV client and server
roachpb.SpanConfig KV server, span-config reconciler
roachpb.Value MVCC, KV, SQL
roachpb.NodeDescriptor gossip, RPC dialer, allocator
roachpb.TenantID every multi-tenant code path

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

roachpb – CockroachDB wiki | Factory