Documentation ¶
Overview ¶
Example ¶
newClient := func() (*mongo.Client, bool, error) { var client *mongo.Client // ... return client, true, nil } // Setup g := NewWUID("default", nil) _ = g.LoadH28FromMongo(newClient, "test", "wuid", "default") // Generate for i := 0; i < 10; i++ { fmt.Printf("%#016x\n", g.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 sets your own h28 verifier
func WithSection ¶
WithSection adds a section ID to the generated numbers. The section ID must be in between [0, 7].
type WUID ¶
type WUID struct {
// contains filtered or unexported fields
}
WUID is an extremely fast unique number generator.
func (*WUID) LoadH28FromMongo ¶
LoadH28FromMongo adds 1 to a specific number in your MongoDB, fetches its new value, and then sets that as the high 28 bits of the unique numbers that Next generates.
Click to show internal directories.
Click to hide internal directories.