roachpb

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxTenantID = MakeTenantID(math.MaxUint64)

MaxTenantID is the maximum ID of a (non-system) tenant in a multi-tenant cluster.

View Source
var MinTenantID = MakeTenantID(2)

MinTenantID is the minimum ID of a (non-system) tenant in a multi-tenant cluster.

View Source
var SystemTenantID = MakeTenantID(1)

SystemTenantID is the ID associated with the system's internal tenant in a multi-tenant cluster and the only tenant in a single-tenant cluster.

The system tenant differs from all other tenants in four important ways: 1. the system tenant's keyspace is not prefixed with a tenant specifier. 2. the system tenant is created by default during cluster initialization. 3. the system tenant is always present and can never be destroyed. 4. the system tenant has the ability to create and destroy other tenants.

Functions

func BytesNext

func BytesNext(b []byte) []byte

BytesNext returns the next possible byte slice, using the extra capacity of the provided slice if possible, and if not, appending an \x00.

func IsSystemTenantID

func IsSystemTenantID(id uint64) bool

IsSystemTenantID returns whether the provided ID corresponds to that of the system tenant.

func NewContextForTenant

func NewContextForTenant(ctx context.Context, tenID TenantID) context.Context

NewContextForTenant creates a new context with tenant information attached.

Types

type Key

type Key []byte

Key is a custom type for a byte string in proto messages which refer to Cockroach keys.

func (Key) Compare

func (k Key) Compare(b Key) int

Compare compares the two Keys.

func (Key) Equal

func (k Key) Equal(l Key) bool

Equal returns whether two keys are identical.

func (Key) IsPrev

func (k Key) IsPrev(m Key) bool

IsPrev is a more efficient version of k.Next().Equal(m).

func (Key) Next

func (k Key) Next() Key

Next returns the next key in lexicographic sort order. The method may only take a shallow copy of the Key, so both the receiver and the return value should be treated as immutable after.

type TenantID

type TenantID struct {
	// contains filtered or unexported fields
}

A TenantID is a unique ID associated with a tenant in a multi-tenant cluster. Each tenant is granted exclusive access to a portion of the keyspace and a collection of SQL tables in that keyspace which comprise a "logical" cluster.

The type is intentionally opaque to require deliberate use.

func MakeTenantID

func MakeTenantID(id uint64) TenantID

MakeTenantID constructs a new TenantID from the provided uint64.

func TenantFromContext

func TenantFromContext(ctx context.Context) (tenID TenantID, ok bool)

TenantFromContext returns the tenant information in ctx if it exists.

func (TenantID) String

func (t TenantID) String() string

String implements the fmt.Stringer interface.

func (TenantID) ToUint64

func (t TenantID) ToUint64() uint64

ToUint64 returns the TenantID as a uint64.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL