Documentation ¶
Index ¶
Constants ¶
View Source
const ( //StartTimeEnvName is the env key for ID generating start time StartTimeEnvName = "SNOWFLAKEID_START_TIME" //MachineIDEnvName is the env key for machine id MachineIDEnvName = "SNOWFLAKEID_MACHINE_ID" )
StartTimeEnvName ...
Variables ¶
View Source
var BenchmarkConfig = ConstructConfig(40, 15, 8)
BenchmarkConfig is a high performance setting for benchmark
40 bits timestamp 15 bits seq 8 bits machine id
View Source
var CommonConfig = ConstructConfig(40, 7, 16)
CommonConfig is the recommended setting for most applications
40 bits timestamp 7 bits seq 16 bits machine id
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config maintains the settings for id generating
func ConstructConfig ¶
ConstructConfig creates an instance of FastIDConfig with the given settings
func ConstructConfigWithMachineID ¶
ConstructConfigWithMachineID creates an config with machine id, in case you don't want to use the lower 16 bits of the IP address.
func (*Config) GenInt64ID ¶
GenInt64ID generates unique int64 IDs with the setting in the methond owner
func (*Config) GetSeqFromID ¶
GetSeqFromID extracts seq number from an existing ID
func (*Config) GetTimeFromID ¶
GetTimeFromID extracts timestamp from an existing ID
Click to show internal directories.
Click to hide internal directories.