pk

package module
v0.0.0-...-1a563a3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MaxTIDSerialN     = tidCounterMax - 1
	MaxTIDSerialBatch = tidTimeMax - 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Salt

type Salt []byte

type TID

type TID struct {
	// contains filtered or unexported fields
}

TID is an 63-bit "temporal" ID that is generated from current time and a magic numbers.

func NewRawValueTID

func NewRawValueTID(v int64) (t TID)

func NewSerialTID

func NewSerialTID(batch uint64, n uint) TID

func NewTID

func NewTID(now time.Time, n, c uint, virtual bool) TID

func ParseTID

func ParseTID(s string) (TID, error)

ParseTID converts string generated by the TIDs String function into a TID.

func ParseTIDBytes

func ParseTIDBytes(raw []byte) (TID, error)

ParseTIDBytes converts raw bytes into a TID.

func (*TID) ApplyRawValue

func (t *TID) ApplyRawValue(v int64)

func (TID) Bytes

func (t TID) Bytes() []byte

func (TID) IsVirtual

func (t TID) IsVirtual() bool

func (TID) IsZero

func (t TID) IsZero() bool

func (TID) MarshalJSON

func (t TID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (TID) RawValue

func (t TID) RawValue() int64

func (*TID) Scan

func (t *TID) Scan(value any) error

Scan implements the sql.Scanner interface.

func (TID) Serial

func (t TID) Serial() int64

func (TID) String

func (t TID) String() string

func (TID) Time

func (t TID) Time() time.Time

func (*TID) UnmarshalJSON

func (t *TID) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (TID) Value

func (t TID) Value() (driver.Value, error)

Value implements the sql.Valuer interface.

type TIDSource

type TIDSource struct {
	// contains filtered or unexported fields
}

func NewTIDSource

func NewTIDSource(now time.Time, n uint) *TIDSource

func (*TIDSource) Next

func (src *TIDSource) Next(now time.Time) TID

func (*TIDSource) NextVirtual

func (src *TIDSource) NextVirtual(now time.Time) TID

type UID

type UID struct {
	// contains filtered or unexported fields
}

UID is a 120-bit (15 byte) "content ID" for arbitrary binary data, with collision chance of 1 in ~2.66 trillion on trillion unique items.

func NewUID

func NewUID(src ...any) (UID, error)

func ParseUID

func ParseUID(s string) (UID, error)

func ParseUIDBytes

func ParseUIDBytes(b []byte) (UID, error)

func (UID) Bytes

func (u UID) Bytes() []byte

func (UID) Hex

func (u UID) Hex() string

Hex returns a hex encoded presentation of a ID. This should be used when using IDs as filenames on case-insensitive filesystems.

func (UID) MarshalJSON

func (t UID) MarshalJSON() ([]byte, error)

func (UID) String

func (u UID) String() string

func (*UID) UnmarshalJSON

func (u *UID) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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