-
Notifications
You must be signed in to change notification settings - Fork 316
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
- Use
func New(st Settings) (*Sonyflake, error)
func NewSonyflake(st Settings) *Sonyflake
-
NextID
returnsint64
instead ofuint64
func (sf *Sonyflake) NextID() (int64, error)