Documentation ¶
Overview ¶
Package cursor implements time-ordered item cursors for an event log.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
A Cursor is a unique identifier for an item in a time-ordered event log. It is safe to copy and compare cursors by value.
func (Cursor) Before ¶
Before reports whether c is prior to o in time ordering. This comparison ignores sequence numbers.
func (Cursor) Diff ¶
Diff returns the time duration between c and o. The duration is negative if c is before o in time order.
func (Cursor) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. A zero cursor marshals as "", otherwise the format used by the String method.
func (*Cursor) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. An empty text unmarshals without error to a zero cursor.
type Source ¶
type Source struct { // This function is called to produce the current time index. // If nil, it defaults to time.Now().UnixNano(). TimeIndex func() int64 // The current counter value used for sequence number generation. It is // incremented in-place each time a cursor is generated. Counter int64 }
A Source produces cursors based on a time index generator and a sequence counter. A zero-valued Source is ready for use with defaults as described.