Documentation
¶
Index ¶
Constants ¶
View Source
const ( // TypeMySQL - uid use mysql TypeMySQL = "mysql" // TypeRedis - uid use redis TypeRedis = "redis" // TypeSnowFlake - uid use snow flake TypeSnowFlake = "snow_flake" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Redis config
Key string `json:"key"`
// public param
Server string `json:"server"`
User string `json:"user"`
Password string `json:"password"`
Port int64 `json:"port"`
// Snow flake node id
NodeID int64 `json:"node_id"`
// Mysql config
InitValue int64 `json:"init_value"`
Step int64 `json:"step"`
DBName string `json:"db_name"`
TableName string `json:"table_name"`
AutoCreateTable bool `json:"auto_create_table"`
// Extend fields
// Extended fields can be used if there is a special implementation
Extend1 string `json:"extend_1"`
Extend2 string `json:"extend_2"`
}
Config - uid config
type UID ¶
type UID interface {
// has int32 uid
HasInt32() bool
// next int32 uid
NextUID32() int32
// next int64 uid
NextUID64() int64
// close connection
Close() error
// start gc routine based on config settings.
StartAndGC(config Config) error
}
UID interface contains all behaviors for UID adapter. usage:
uid.Register("uid", uid.NewUID)
Click to show internal directories.
Click to hide internal directories.