sequence

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package sequence provides per-shard monotonic sequence counters. Each counter is an independent atomic uint64 that increments without locking, giving O(1) Next calls with no contention between shards.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counters

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

Counters holds one atomic counter per shard group. Create with NewCounters; safe for concurrent use by multiple goroutines.

func NewCounters

func NewCounters(numShards uint32) *Counters

NewCounters allocates a Counters with numShards independent counters, all starting at zero. numShards should equal shard.Engine.NumGroups().

func (*Counters) Next

func (c *Counters) Next(shardIdx uint32) uint64

Next atomically increments the counter for shardIdx and returns the value before the increment. The first call returns 0, the second 1, and so on.

shardIdx must be in [0, numShards). Behaviour is undefined if it is out of range (index panic).

Jump to

Keyboard shortcuts

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