Documentation ¶
Overview ¶
This package provides immutable UUID structs and the functions NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 and 5 UUIDs as specified in RFC 4122.
Copyright (C) 2011 by Krzysztof Kowalik <chris@nu7hat.ch>
Index ¶
Constants ¶
View Source
const ( SequenceBits = 10 MachineIDBits = 16 TimestampShift = SequenceBits + MachineIDBits TimeUnitBits = 63 - TimestampShift Twepoch = 1577836800_000_000_000 // custom epoch in nanosecond, (2020-01-01 00:00:00 UTC) )
View Source
const ( ReservedNCS byte = 0x80 ReservedRFC4122 byte = 0x40 ReservedMicrosoft byte = 0x20 ReservedFuture byte = 0x00 )
The UUID reserved variants.
View Source
const DefaultSeqStep = 2000
Variables ¶
View Source
var (
NamespaceDNS, _ = ParseHex("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
NamespaceURL, _ = ParseHex("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
NamespaceOID, _ = ParseHex("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
NamespaceX500, _ = ParseHex("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
)
The following standard UUIDs are for use with NewV3() or NewV5().
View Source
var ErrCannotPutEtcd = errors.New("cannot put counter to etcd")
Functions ¶
func MustCreateGUID ¶
func MustCreateGUID() string
Types ¶
type KeyValue ¶ added in v1.0.2
type KeyValue struct { // key is the key in bytes. An empty key is not allowed. Key string `json:"key,omitempty"` // create_revision is the revision of last creation on this key. CreateRevision string `json:"create_revision,omitempty"` // mod_revision is the revision of last modification on this key. ModRevision string `json:"mod_revision,omitempty"` // version is the version of the key. A deletion resets // the version to zero and any modification of the key // increases its version. Version string `json:"version,omitempty"` // value is the value held by the key, in bytes. Value string `json:"value,omitempty"` // lease is the ID of the lease that attached to key. // When the attached lease expires, the key will be deleted. // If lease is 0, then no lease is attached to the key. Lease string `json:"lease,omitempty"` }
type PutResponse ¶ added in v1.0.2
type PutResponse struct { Header *ResponseHeader `json:"header,omitempty"` // if prev_kv is set in the request, the previous key-value pair will be returned. PrevKv *KeyValue `json:"prev_kv,omitempty"` }
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func (*RedisStore) Close ¶
func (s *RedisStore) Close()
func (*RedisStore) Init ¶ added in v1.0.2
func (s *RedisStore) Init() error
func (*RedisStore) MustNext ¶ added in v1.0.2
func (s *RedisStore) MustNext() int64
func (*RedisStore) Next ¶ added in v1.0.2
func (s *RedisStore) Next() (int64, error)
type ResponseHeader ¶ added in v1.0.2
type ResponseHeader struct { // cluster_id is the ID of the cluster which sent the response. ClusterId string `json:"cluster_id,omitempty"` // member_id is the ID of the member which sent the response. MemberId string `json:"member_id,omitempty"` // revision is the key-value store revision when the request was applied. // For watch progress responses, the header.revision indicates progress. All future events // recieved in this stream are guaranteed to have a higher revision number than the // header.revision number. Revision string `json:"revision,omitempty"` // raft_term is the raft term when the request was applied. RaftTerm string `json:"raft_term,omitempty"` }
type SequenceID ¶
type SequenceID struct {
// contains filtered or unexported fields
}
func NewSequenceID ¶
func NewSequenceID(store Storage, step int32) *SequenceID
func (*SequenceID) Init ¶
func (s *SequenceID) Init() (err error)
func (*SequenceID) Next ¶
func (s *SequenceID) Next() int64
type UUID ¶
type UUID [16]byte
A UUID representation compliant with specification in RFC 4122 document.
func ParseHex ¶
ParseHex creates a UUID object from given hex string representation. Function accepts UUID string in following formats:
uuid.ParseHex("6ba7b814-9dad-11d1-80b4-00c04fd430c8") uuid.ParseHex("{6ba7b814-9dad-11d1-80b4-00c04fd430c8}") uuid.ParseHex("urn:uuid:6ba7b814-9dad-11d1-80b4-00c04fd430c8")
Click to show internal directories.
Click to hide internal directories.