Documentation
¶
Index ¶
- Constants
- Variables
- func Compare(id1, id2 ID) int
- type FixedTimeGenerator
- type Generator
- type ID
- func (d ID) After(other ID) bool
- func (d ID) Before(other ID) bool
- func (d ID) Bytes() []byte
- func (d ID) Equal(other ID) bool
- func (d ID) Marshal() ([]byte, error)
- func (d ID) MarshalJSON() ([]byte, error)
- func (d ID) MarshalText() ([]byte, error)
- func (d ID) MarshalTo(dst []byte) (int, error)
- func (d ID) RandomBytes() []byte
- func (d ID) Sequence() uint32
- func (d ID) Size() int
- func (id ID) String() string
- func (d ID) Time() time.Time
- func (d *ID) Unmarshal(b []byte) error
- func (d *ID) UnmarshalJSON(b []byte) error
- func (d *ID) UnmarshalText(b []byte) error
- func (d ID) WorkerID() (wid WorkerID)
- type WorkerID
Constants ¶
View Source
const (
Size = timestampLength + workerIDLength + sequenceLength + randomLength
)
Variables ¶
Functions ¶
Types ¶
type FixedTimeGenerator ¶
type FixedTimeGenerator struct {
// contains filtered or unexported fields
}
func NewFixedTimeGenerator ¶
func NewFixedTimeGenerator(t time.Time) *FixedTimeGenerator
func (*FixedTimeGenerator) Next ¶
func (g *FixedTimeGenerator) Next() ID
Next returns the next id. It returns an error if New() fails. It is safe for concurrent use.
type ID ¶
48bit: timestamp 32bit: worker id (defaults to MAC Address) 24bit: sequence number 24bit: random number
func MustParseBytes ¶
func Next ¶
func Next() ID
Next returns the next id from the global generator It is safe for concurrent use.
func ParseBytes ¶
func (ID) MarshalJSON ¶
func (ID) MarshalText ¶
func (ID) RandomBytes ¶
RandomBytes returns the random stored in the ID
func (*ID) UnmarshalJSON ¶
func (*ID) UnmarshalText ¶
Click to show internal directories.
Click to hide internal directories.