cockroach: Index | Files

package idalloc

import ""


Package Files


type Allocator Uses

type Allocator struct {
    // contains filtered or unexported fields

An Allocator is used to increment a key in allocation blocks of arbitrary size.

Note: if all you want is to increment a key and retry on retryable errors, see client.IncrementValRetryable().

func NewAllocator Uses

func NewAllocator(
    ambient log.AmbientContext,
    idKey roachpb.Key,
    db *client.DB,
    blockSize uint32,
    stopper *stop.Stopper,
) (*Allocator, error)

NewAllocator creates a new ID allocator which increments the specified key in allocation blocks of size blockSize. If the key exists, it's assumed to have an int value (and it needs to be positive since id 0 is a sentinel used internally by the allocator that can't be generated). The first value returned is the existing value + 1, or 1 if the key did not previously exist.

func (*Allocator) Allocate Uses

func (ia *Allocator) Allocate(ctx context.Context) (uint32, error)

Allocate allocates a new ID from the global KV DB.

Package idalloc imports 11 packages (graph) and is imported by 1 packages. Updated 2019-07-27. Refresh now. Tools for package owners.