Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClockNotExist = errors.New("clock doesn't exist")
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface { // Time is used to return the current value of the lamport clock Time() Time // Increment is used to return the value of the lamport clock and increment it afterwards Increment() (Time, error) // Witness is called to update our local clock if necessary after // witnessing a clock value received from another process Witness(time Time) error }
Clock is a Lamport logical clock
type MemClock ¶ added in v0.8.0
type MemClock struct {
// contains filtered or unexported fields
}
MemClock is a thread safe implementation of a lamport clock. It uses efficient atomic operations for all of its functions, falling back to a heavy lock only if there are enough CAS failures.
func NewMemClock ¶ added in v0.8.0
func NewMemClock() *MemClock
NewMemClock create a new clock with the value 1. Value 0 is considered as invalid.
func NewMemClockWithTime ¶ added in v0.8.0
NewMemClockWithTime create a new clock with a value.
func (*MemClock) Increment ¶ added in v0.8.0
Increment is used to return the value of the lamport clock and increment it afterwards
type PersistedClock ¶ added in v0.8.0
type PersistedClock struct { *MemClock // contains filtered or unexported fields }
func LoadPersistedClock ¶ added in v0.8.0
func LoadPersistedClock(root billy.Filesystem, filePath string) (*PersistedClock, error)
LoadPersistedClock load a persisted Lamport clock from a file
func NewPersistedClock ¶ added in v0.8.0
func NewPersistedClock(root billy.Filesystem, filePath string) (*PersistedClock, error)
NewPersistedClock create a new persisted Lamport clock
func (*PersistedClock) Increment ¶ added in v0.8.0
func (pc *PersistedClock) Increment() (Time, error)
Increment is used to return the value of the lamport clock and increment it afterwards
func (*PersistedClock) Witness ¶ added in v0.8.0
func (pc *PersistedClock) Witness(time Time) error
Witness is called to update our local clock if necessary after witnessing a clock value received from another process
func (*PersistedClock) Write ¶ added in v0.8.0
func (pc *PersistedClock) Write() error