Documentation ¶
Index ¶
Constants ¶
View Source
const IPUnknown = "AAAAAAA"
IPUnknown represents unknown IP address.
Variables ¶
This section is empty.
Functions ¶
func SetDefault ¶
func SetDefault(gen Generator)
SetDefault changes the default generator.
The default generator may be changed by the main program, but generally library code shall not call this function.
Types ¶
type Generator ¶
type Generator interface { // Gen generates a new log ID string, it should always return // a valid log ID, and don't generate duplicate log IDs. Gen() string }
type V1Gen ¶ added in v2.12.0
type V1Gen struct {
// contains filtered or unexported fields
}
V1Gen is a v1 log ID generator.
A v1 log ID is consisted of the following parts:
- 17 bytes milli timestamp
- 16 bytes hash of the machine ID of current host if available, else 16 bytes random data
- 10 bytes random data, with 1 bit to mark UTC timezone
- 1 byte version flag "1"
type V2Gen ¶ added in v2.12.0
type V2Gen struct {
// contains filtered or unexported fields
}
V2Gen is a v2 log ID generator.
A v2 log ID is consisted by the following parts:
- 17 bytes milli timestamp
- 26 bytes IPv6 address, or 7 bytes IPv4 address, in base32 form
- 10 bytes random data, with 1 bit to mark UTC timezone
- 1 byte version flag "2"
Click to show internal directories.
Click to hide internal directories.