Documentation ¶
Overview ¶
Example ¶
newClient := func() (*mongo.Client, bool, error) { var client *mongo.Client // ... return client, true, nil } // Setup w := NewWUID("alpha", nil) err := w.LoadH28FromMongo(newClient, "test", "wuid", "default") if err != nil { panic(err) } // Generate for i := 0; i < 10; i++ { fmt.Printf("%#016x\n", w.Next()) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
func WithH28Verifier ¶
WithH28Verifier adds an extra verifier for the high 28 bits.
func WithObfuscation ¶
WithObfuscation enables number obfuscation.
func WithSection ¶
WithSection brands a section ID on each generated number. A section ID must be in between [0, 7].
type WUID ¶
type WUID struct {
// contains filtered or unexported fields
}
WUID is an extremely fast universal unique identifier generator.
func (*WUID) LoadH28FromMongo ¶
LoadH28FromMongo adds 1 to a specific number in MongoDB and fetches its new value. The new value is used as the high 28 bits of all generated numbers. In addition, all the arguments passed in are saved for future renewal.
Click to show internal directories.
Click to hide internal directories.