uid

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllowNone   = uint32(0)      // ID has no privileges.
	AllowMaster = uint32(1 << 0) // ID should be allowed to generate other IDs.

)
View Source
const (
	Offset = 1555770000
)

Variables

View Source
var (
	// next is the next identifier. It is time in millsecond
	// to avoid collisions of ids between process restarts.
	Next = uint32(
		time.Date(2070, 1, 1, 0, 0, 0, 0, time.UTC).Sub(TimeNow()),
	)
)

Functions

func NewApoch

func NewApoch() uint32

func NewUnique

func NewUnique() uint32

func TimeNow

func TimeNow() time.Time

TimeNow returns current wall time in UTC rounded to milliseconds.

Types

type ID

type ID []byte

ID represents a unique ID for client connection.

func CachedClientID

func CachedClientID(contract uint32) (ID, error)

CachedClientID return cached client Id

func Decode

func Decode(buffer []byte, mac *crypto.MAC) (ID, error)

func NewClientID

func NewClientID(master uint16) (ID, error)

NewClientID generates a new primary client Id.

func NewSecondaryClientID

func NewSecondaryClientID(master ID) (ID, error)

NewSecondaryClientID generates a secondary client Id.

func (ID) Contract

func (id ID) Contract() uint32

Contract gets the contract id.

func (ID) Encode

func (id ID) Encode(mac *crypto.MAC) string

func (ID) Epoch

func (id ID) Epoch() uint32

Apoch gets the Apoch for the ID

func (ID) IsPrimary

func (id ID) IsPrimary() bool

IsPrimary gets whether the ID is a primary client Id.

func (ID) Permissions

func (id ID) Permissions() uint32

Permissions gets the permission flags.

func (ID) Primary

func (id ID) Primary() uint16

Primary gets the primary client Id

func (ID) SetContract

func (id ID) SetContract(value uint32)

SetContract sets the contract id.

func (ID) SetEpoch

func (id ID) SetEpoch(value uint32)

SetApoch sets the Apoch for the ID

func (ID) SetPermissions

func (id ID) SetPermissions(value uint32)

SetPermissions sets the permission flags.

func (ID) SetPrimary

func (id ID) SetPrimary(value uint16)

SetPrimary sets the primary client Id

type LID

type LID uint32

LID represents a process-wide unique ID.

func NewLID

func NewLID() LID

NewID generates a new, process-wide unique ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL