time

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EpochScheme = newEpochScheme()
View Source
var LogicalScheme = newLogicalScheme()

LogicalScheme is a default Scheme for logical time

View Source
var PhysicalScheme = newPhysicalScheme()

Functions

This section is empty.

Types

type Clock

type Clock interface {
	// Scheme returns the clock's scheme
	Scheme() Scheme
	// Get gets the current timestamp
	Get() Timestamp
	// Increment increments the clock
	Increment() Timestamp
	// Update updates the timestamp
	Update(Timestamp) Timestamp
}

Clock is an interface for clocks

func NewCompositeClock

func NewCompositeClock(schemes ...Scheme) Clock

NewCompositeClock creates a new composite clock

func NewEpochClock

func NewEpochClock() Clock

NewEpochClock creates a new epoch clock

func NewLogicalClock

func NewLogicalClock() Clock

NewLogicalClock creates a new logical clock

func NewPhysicalClock

func NewPhysicalClock() Clock

NewPhysicalClock creates a new physical clock

type Codec

type Codec interface {
	EncodeTimestamp(Timestamp) metaapi.Timestamp
	DecodeTimestamp(metaapi.Timestamp) (Timestamp, error)
}

Codec is a time codec

type CompositeClock

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

CompositeClock is a clock that produces CompositeTimestamps

func (*CompositeClock) Get

func (c *CompositeClock) Get() Timestamp

func (*CompositeClock) Increment

func (c *CompositeClock) Increment() Timestamp

func (*CompositeClock) Scheme

func (c *CompositeClock) Scheme() Scheme

func (*CompositeClock) Update

func (c *CompositeClock) Update(t Timestamp) Timestamp

type CompositeTimestamp

type CompositeTimestamp struct {
	Timestamps []Timestamp
	// contains filtered or unexported fields
}

CompositeTimestamp is a composite Timestamp implementation

func (CompositeTimestamp) After

func (t CompositeTimestamp) After(u Timestamp) bool

func (CompositeTimestamp) Before

func (t CompositeTimestamp) Before(u Timestamp) bool

func (CompositeTimestamp) Equal

func (t CompositeTimestamp) Equal(u Timestamp) bool

func (CompositeTimestamp) Scheme

func (t CompositeTimestamp) Scheme() Scheme

type CompositeTimestampCodec

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

CompositeTimestampCodec is a codec for Composite timestamps

func (CompositeTimestampCodec) DecodeTimestamp

func (c CompositeTimestampCodec) DecodeTimestamp(timestamp metaapi.Timestamp) (Timestamp, error)

func (CompositeTimestampCodec) EncodeTimestamp

func (c CompositeTimestampCodec) EncodeTimestamp(timestamp Timestamp) metaapi.Timestamp

type Epoch

type Epoch uint64

type EpochClock

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

EpochClock is a clock that produces EpochTimestamps

func (*EpochClock) Get

func (c *EpochClock) Get() Timestamp

func (*EpochClock) Increment

func (c *EpochClock) Increment() Timestamp

func (*EpochClock) Scheme

func (c *EpochClock) Scheme() Scheme

func (*EpochClock) Update

func (c *EpochClock) Update(t Timestamp) Timestamp

type EpochTimestamp

type EpochTimestamp struct {
	Epoch Epoch
	Time  LogicalTime
}

EpochTimestamp is a Timestamp based on an Epoch and LogicalTime

func (EpochTimestamp) After

func (t EpochTimestamp) After(u Timestamp) bool

func (EpochTimestamp) Before

func (t EpochTimestamp) Before(u Timestamp) bool

func (EpochTimestamp) Equal

func (t EpochTimestamp) Equal(u Timestamp) bool

func (EpochTimestamp) Scheme

func (t EpochTimestamp) Scheme() Scheme

type EpochTimestampCodec

type EpochTimestampCodec struct{}

EpochTimestampCodec is a codec for epoch timestamps

func (EpochTimestampCodec) DecodeTimestamp

func (c EpochTimestampCodec) DecodeTimestamp(timestamp metaapi.Timestamp) (Timestamp, error)

func (EpochTimestampCodec) EncodeTimestamp

func (c EpochTimestampCodec) EncodeTimestamp(timestamp Timestamp) metaapi.Timestamp

type LogicalClock

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

LogicalClock is a clock that produces LogicalTimestamps

func (*LogicalClock) Get

func (c *LogicalClock) Get() Timestamp

func (*LogicalClock) Increment

func (c *LogicalClock) Increment() Timestamp

func (*LogicalClock) Scheme

func (c *LogicalClock) Scheme() Scheme

func (*LogicalClock) Update

func (c *LogicalClock) Update(t Timestamp) Timestamp

type LogicalTime

type LogicalTime uint64

LogicalTime is an instant in logical time

type LogicalTimestamp

type LogicalTimestamp struct {
	Time LogicalTime
}

LogicalTimestamp is a logical timestamp

func (LogicalTimestamp) After

func (t LogicalTimestamp) After(u Timestamp) bool

func (LogicalTimestamp) Before

func (t LogicalTimestamp) Before(u Timestamp) bool

func (LogicalTimestamp) Equal

func (t LogicalTimestamp) Equal(u Timestamp) bool

func (LogicalTimestamp) Increment

func (t LogicalTimestamp) Increment() LogicalTimestamp

func (LogicalTimestamp) Scheme

func (t LogicalTimestamp) Scheme() Scheme

type LogicalTimestampCodec

type LogicalTimestampCodec struct{}

LogicalTimestampCodec is a codec for logical timestamps

func (LogicalTimestampCodec) DecodeTimestamp

func (c LogicalTimestampCodec) DecodeTimestamp(timestamp metaapi.Timestamp) (Timestamp, error)

func (LogicalTimestampCodec) EncodeTimestamp

func (c LogicalTimestampCodec) EncodeTimestamp(timestamp Timestamp) metaapi.Timestamp

type PhysicalClock

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

PhysicalClock is a clock that produces PhysicalTimestamps

func (*PhysicalClock) Get

func (c *PhysicalClock) Get() Timestamp

func (*PhysicalClock) Increment

func (c *PhysicalClock) Increment() Timestamp

func (*PhysicalClock) Scheme

func (c *PhysicalClock) Scheme() Scheme

func (*PhysicalClock) Update

func (c *PhysicalClock) Update(update Timestamp) Timestamp

type PhysicalTime

type PhysicalTime time.Time

PhysicalTime is an instant in physical time

type PhysicalTimestamp

type PhysicalTimestamp struct {
	Time PhysicalTime
}

PhysicalTimestamp is a Timestamp based on PhysicalTime

func (PhysicalTimestamp) After

func (t PhysicalTimestamp) After(u Timestamp) bool

func (PhysicalTimestamp) Before

func (t PhysicalTimestamp) Before(u Timestamp) bool

func (PhysicalTimestamp) Equal

func (t PhysicalTimestamp) Equal(u Timestamp) bool

func (PhysicalTimestamp) Scheme

func (t PhysicalTimestamp) Scheme() Scheme

type PhysicalTimestampCodec

type PhysicalTimestampCodec struct{}

PhysicalTimestampCodec is a codec for physical timestamps

func (PhysicalTimestampCodec) DecodeTimestamp

func (c PhysicalTimestampCodec) DecodeTimestamp(timestamp metaapi.Timestamp) (Timestamp, error)

func (PhysicalTimestampCodec) EncodeTimestamp

func (c PhysicalTimestampCodec) EncodeTimestamp(timestamp Timestamp) metaapi.Timestamp

type Scheme

type Scheme interface {
	// Name returns the scheme's name
	Name() string

	// Codec returns the scheme's codec
	Codec() Codec

	// NewClock creates a new clock
	NewClock() Clock
}

Scheme it a time scheme

type Timestamp

type Timestamp interface {
	Scheme() Scheme
	Before(Timestamp) bool
	After(Timestamp) bool
	Equal(Timestamp) bool
}

Timestamp is a timestamp

func NewCompositeTimestamp

func NewCompositeTimestamp(timestamps ...Timestamp) Timestamp

NewCompositeTimestamp creates a new composite Timestamp from the given set of Timestamps

func NewEpochTimestamp

func NewEpochTimestamp(epoch Epoch, time LogicalTime) Timestamp

NewEpochTimestamp creates a new Epoch based Timestamp

func NewLogicalTimestamp

func NewLogicalTimestamp(time LogicalTime) Timestamp

NewLogicalTimestamp creates a new logical Timestamp

func NewPhysicalTimestamp

func NewPhysicalTimestamp(time PhysicalTime) Timestamp

NewPhysicalTimestamp creates a new Timestamp based in PhysicalTime

func NewTimestamp

func NewTimestamp(meta metaapi.Timestamp) Timestamp

NewTimestamp creates new object timestamp from the given proto timestamp

Jump to

Keyboard shortcuts

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