Documentation
¶
Overview ¶
Package sequence provides atomic sequence counters for XxSql.
Index ¶
- type Manager
- func (m *Manager) BatchNextValue(name string, count int) ([]int64, error)
- func (m *Manager) Close() error
- func (m *Manager) CreateSequence(config SequenceConfig) error
- func (m *Manager) CurrentValue(name string) (int64, error)
- func (m *Manager) DropSequence(name string) error
- func (m *Manager) Exists(name string) bool
- func (m *Manager) Flush() error
- func (m *Manager) GetRange(name string, count int) (start, end int64, err error)
- func (m *Manager) GetSequence(name string) (*Sequence, error)
- func (m *Manager) ListSequences() []string
- func (m *Manager) Load() error
- func (m *Manager) NextValue(name string) (int64, error)
- func (m *Manager) Persist() error
- func (m *Manager) Reset(name string) error
- func (m *Manager) SetCurrentValue(name string, value int64) error
- func (m *Manager) Stats() Stats
- type Sequence
- type SequenceConfig
- type Stats
- type WALLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple sequences.
func NewManager ¶
NewManager creates a new sequence manager.
func (*Manager) BatchNextValue ¶
BatchNextValue returns multiple values from a sequence.
func (*Manager) CreateSequence ¶
func (m *Manager) CreateSequence(config SequenceConfig) error
CreateSequence creates a new sequence.
func (*Manager) CurrentValue ¶
CurrentValue returns the current value of a sequence without advancing it.
func (*Manager) DropSequence ¶
DropSequence drops a sequence.
func (*Manager) GetRange ¶
GetRange returns a range of values from a sequence. This is more efficient than multiple NextValue calls for bulk operations.
func (*Manager) GetSequence ¶
GetSequence returns information about a sequence.
func (*Manager) ListSequences ¶
ListSequences returns a list of all sequence names.
func (*Manager) NextValue ¶
NextValue returns the next value from a sequence. This is thread-safe and uses atomic operations.
func (*Manager) SetCurrentValue ¶
SetCurrentValue sets the current value of a sequence. This is used for recovery and administrative purposes.
type Sequence ¶
type Sequence struct {
Name string
Current int64
Increment int64
MinValue int64
MaxValue int64
StartValue int64
Cycle bool
CacheSize int32 // Number of values to cache in memory
CacheEnd int64 // End of current cache range
Created time.Time
LastUpdated time.Time
}
Sequence represents a named sequence counter.
type SequenceConfig ¶
type SequenceConfig struct {
Name string
Start int64
Increment int64
MinValue int64
MaxValue int64
Cycle bool
CacheSize int32
}
SequenceConfig holds configuration for creating a sequence.
func DefaultSequenceConfig ¶
func DefaultSequenceConfig(name string) SequenceConfig
DefaultSequenceConfig returns default configuration for a sequence.