Versions in this module Expand all Collapse all v1 v1.1.1 Jul 19, 2026 v1.1.0 Jul 19, 2026 Changes in this version + const DefaultClockRollbackToleranceMs + const MaxNode + const MaxSequence + const MaxTimestamp + const MaxType + const NodeBits + const NodeShift + const OrbitEpochUnixMs + const SequenceBits + const TimestampBits + const TimestampShift + const TypeBits + const TypeShift + func Encode(fields Fields) (uint64, error) + func FromDecimalString(input string) (uint64, error) + func FromUnixTimeMs(unixMs int64) int64 + func GetNode(id any) (int, error) + func GetSequence(id any) (int, error) + func GetTimestamp(id any) (uint64, error) + func GetType(id any) (int, error) + func IsValid(id any) bool + func ToDecimalString(id uint64) string + func ToHexString(id uint64) string + func ToUnixTimeMs(timestamp uint64) uint64 + type Clock interface + CurrentOrbitTimestampMs func() int64 + func SystemClock() Clock + type DecisionAction string + const DecisionError + const DecisionIssue + const DecisionWait + const DecisionWaitNextMs + type Error struct + Code ErrorCode + Message string + func (e *Error) Error() string + type ErrorCode string + const ClockRollback + const InvalidDecimal + const InvalidNode + const InvalidSequence + const InvalidTimestamp + const InvalidType + const NodeOwnershipLost + const SequenceExhausted + type Fields struct + Node int + Sequence int + Timestamp uint64 + Type int + func Decode(id uint64) Fields + func Parse(id any) (Fields, error) + type GenerateDecision struct + Action DecisionAction + Error ErrorCode + FromTimestamp uint64 + Sequence int + Timestamp uint64 + WaitUntilTimestamp uint64 + type Generator struct + func NewGenerator(options GeneratorOptions) (*Generator, error) + func (g *Generator) Decide(typ int, nowTimestamp ...int64) GenerateDecision + func (g *Generator) Generate(typ int) (uint64, error) + func (g *Generator) GetLastTimestamp() uint64 + func (g *Generator) GetSequence() int + func (g *Generator) Node() int + func (g *Generator) RestoreState(lastTimestamp uint64, sequence int) error + type GeneratorOptions struct + Clock Clock + ClockRollbackToleranceMs int64 + ConfirmOwnership func() bool + Node int + OnSequenceExhausted SequenceExhaustedMode + type SequenceExhaustedMode string + const SequenceExhaustedFail + const SequenceExhaustedWait