Documentation
¶
Index ¶
Constants ¶
View Source
const ( MaxStep = 10e7 DefaultStep = 2000 // default step DefaultRetry = 3 // default retry times when id allocator preload next segment DefaultPreloadTimeout = 3 * time.Second // default timeout when id allocator preload next segment )
Variables ¶
This section is empty.
Functions ¶
func NewidAllocator ¶
func NewidAllocator(bizTag string) *idAllocator
Types ¶
type IdGenerator ¶
type IdGenerator struct {
// contains filtered or unexported fields
}
func NewIdGenrator ¶
func NewIdGenrator(store IdStore, opts ...Option) *IdGenerator
type Option ¶
type Option func(*IdGenerator)
func With2BytesRandomFilter ¶
func With2BytesRandomFilter() Option
A filter that inserts 16 bits into the lowest part of the id
+-----------------------+ |0|0000.......0000|0...0| +-----------------------+
1bit reserved 47bit incr id 16bit random
1.4 trillion
func WithExpireTime ¶
func WithIdFilter ¶
func WithPreloadRetryTimes ¶
func WithPreloadTimeout ¶
type RedisIdStore ¶
type RedisIdStore struct {
// contains filtered or unexported fields
}
func NewRedisIdStore ¶
func NewRedisIdStore(client *redis.Client) *RedisIdStore
func (*RedisIdStore) GetNextSegment ¶
Click to show internal directories.
Click to hide internal directories.