Skip to content

Draft Specification for V2

Yoshiyuki Mineo edited this page May 5, 2025 · 4 revisions
  • Make bit assignment customizable

    • BitsTime = 63 - BitsSequence - BitsMachineID
    • BitsSequence > 0
    • BitsMachineID > 0
    • BitsSequence + BitsMachineID < 32
  • Make the time unit customizable

type Settings struct {
	BitsSequence   int
	BitsMachineID  int
	TimeUnit       time.Duration
	StartTime      time.Time
	MachineID      func() (int, error)
	CheckMachineID func(int) bool
}
  • Remove NewSonyflake
    • Use New instead
func New(st Settings) (*Sonyflake, error)
func NewSonyflake(st Settings) *Sonyflake
  • NextID returns int64 instead of uint64
func (sf *Sonyflake) NextID() (int64, error)
Clone this wiki locally