id

package
v0.0.0-...-b178995 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package id implements a MongoDB ObjectId like object.

Cursor stored the timestamp and a hash.

(<timestamp encoded in big endian uint64> 8 bytes) + (4 random bytes) = 12 bytes

24 bytes hex-encoded

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

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

ID hold a hex/byte representation of a timestamp and a hash

func FromHex

func FromHex(data string) (*ID, error)

FromHex build an `ID` from an hex encoded string

func FromRaw

func FromRaw(data []byte) *ID

func New

func New(ts int64) (*ID, error)

New initializes an ID for the given timestamp

func (*ID) Cursor

func (id *ID) Cursor() string

func (*ID) Flag

func (id *ID) Flag() byte

Flag returns the attached index flag

func (*ID) MarshalJSON

func (id *ID) MarshalJSON() ([]byte, error)

MarshalJSON implements the necessary interface to allow an `ID` object to be encoded using the standard `encoding/json` package.

func (*ID) Raw

func (id *ID) Raw() []byte

Raw returns the raw cursor

func (*ID) SetCursor

func (id *ID) SetCursor(c string)

func (*ID) SetFlag

func (id *ID) SetFlag(flag byte)

SetFlag allows to temporarily attach the index flag to the ID

func (*ID) SetVersion

func (id *ID) SetVersion(v int64)

func (*ID) String

func (id *ID) String() string

String implements Stringer interface

func (*ID) Ts

func (id *ID) Ts() int64

Ts returns the timestamp component

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the necessary interface to allow an `ID` object to be encoded using the standard `encoding/json` package.

func (*ID) Version

func (id *ID) Version() int64

func (*ID) VersionString

func (id *ID) VersionString() string

Jump to

Keyboard shortcuts

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