time

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MaxLamport is the maximum value stored in lamport.
	MaxLamport = math.MaxUint64

	// MaxDelimiter is the maximum value stored in delimiter.
	MaxDelimiter = math.MaxUint32
)

Variables

View Source
var (
	// InitialActorID represents the initial value of ActorID.
	InitialActorID = &ActorID{}

	// MaxActorID represents the maximum value of ActorID.
	MaxActorID = &ActorID{
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
		math.MaxUint8,
	}

	// ErrInvalidHexString is returned when the given string is not valid hex.
	ErrInvalidHexString = errors.New("invalid hex string")
)
View Source
var (
	// InitialTicket is the initial value of Ticket.
	InitialTicket = NewTicket(
		0,
		0,
		InitialActorID,
	)

	// MaxTicket is the maximum value of Ticket.
	MaxTicket = NewTicket(
		MaxLamport,
		MaxDelimiter,
		MaxActorID,
	)
)

Functions

This section is empty.

Types

type ActorID

type ActorID [actorIDSize]byte

ActorID is bytes represented by the hexadecimal string. It should be generated by unique value.

func ActorIDFromBytes added in v0.1.2

func ActorIDFromBytes(bytes []byte) (*ActorID, error)

ActorIDFromBytes returns the bytes represented by the bytes of decoded hexadecimal string itself.

func ActorIDFromHex

func ActorIDFromHex(str string) (*ActorID, error)

ActorIDFromHex returns the bytes represented by the hexadecimal string str.

func (*ActorID) Bytes added in v0.1.2

func (id *ActorID) Bytes() []byte

Bytes returns the bytes of ActorID itself. If the receiver is nil, it would return empty array of byte.

func (*ActorID) Compare

func (id *ActorID) Compare(other *ActorID) int

Compare returns an integer comparing two ActorID lexicographically. The result will be 0 if id==other, -1 if id < other, and +1 if id > other. If the receiver or argument is nil, it would panic at runtime.

func (*ActorID) Hex added in v0.1.7

func (id *ActorID) Hex() string

Hex returns the hexadecimal encoding of ActorID. If the receiver is nil, it would return empty string.

func (*ActorID) Key added in v0.1.7

func (id *ActorID) Key() string

Key returns the string of ActorID.

type Ticket

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

Ticket is a timestamp of the logical clock. Ticket is immutable. It is created by change.ID.

func NewTicket

func NewTicket(
	lamport uint64,
	delimiter uint32,
	actorID *ActorID,
) *Ticket

NewTicket creates an instance of Ticket.

func (*Ticket) ActorID

func (t *Ticket) ActorID() *ActorID

ActorID returns the actorID value.

func (*Ticket) ActorIDBytes added in v0.1.2

func (t *Ticket) ActorIDBytes() []byte

ActorIDBytes returns the actorID's bytes value.

func (*Ticket) ActorIDHex

func (t *Ticket) ActorIDHex() string

ActorIDHex returns the actorID's hex value.

func (*Ticket) ActorIDKey added in v0.1.7

func (t *Ticket) ActorIDKey() string

ActorIDKey returns the actorID's string value.

func (*Ticket) After

func (t *Ticket) After(other *Ticket) bool

After returns whether the given ticket was created later.

func (*Ticket) AnnotatedString

func (t *Ticket) AnnotatedString() string

AnnotatedString returns a string containing the meta data of the ticket for debugging purpose.

func (*Ticket) Compare

func (t *Ticket) Compare(other *Ticket) int

Compare returns an integer comparing two Ticket. The result will be 0 if id==other, -1 if id < other, and +1 if id > other. If the receiver or argument is nil, it would panic at runtime.

func (*Ticket) Delimiter

func (t *Ticket) Delimiter() uint32

Delimiter returns the delimiter value.

func (*Ticket) Key

func (t *Ticket) Key() string

Key returns the key string for this Ticket.

func (*Ticket) Lamport

func (t *Ticket) Lamport() uint64

Lamport returns the lamport value.

func (*Ticket) SetActorID

func (t *Ticket) SetActorID(actorID *ActorID) *Ticket

SetActorID creates a new instance of Ticket with the given actorID.

Jump to

Keyboard shortcuts

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