Documentation
¶
Index ¶
- type Factory
- func (f *Factory) Build(worker, seq uint32, gap int64) int64
- func (f *Factory) Elapsed() int64
- func (f *Factory) Gap0() int64
- func (f *Factory) Gaps(t time.Time) int64
- func (f *Factory) Mask(seq uint32) uint32
- func (f *Factory) New(wid uint32) *Snowflake
- func (f *Factory) Next(n int64) int64
- func (f *Factory) SeqBits() int
- func (f *Factory) String() string
- func (f *Factory) Tag() string
- func (f *Factory) Unit() int
- func (f *Factory) WorkerBits() int
- type Snowflake
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
func NewFactory ¶
NewFactory creates a snowflake id factory
requirements: 1. MUST generate more than 10 sfids per second 2. MUST be able to generate continuously for 10 years or longer
The `unit` helps mitigate clock rollback to some extent. When the system clock moves backward within the `unit` range, the computed factory gap remains consistent, avoiding conflicts.
func (*Factory) WorkerBits ¶
Click to show internal directories.
Click to hide internal directories.