Documentation
¶
Index ¶
Constants ¶
View Source
const Type primitive.Type = "Log"
Type is the log type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// GetLog gets the log instance of the given name
GetLog(ctx context.Context, name string) (Log, error)
}
Client provides an API for creating IndexedMaps
type Entry ¶
type Entry struct {
// Index is the unique, monotonically increasing, globally unique index of the entry. The index is static
// for the lifetime of a key.
Index Index
// Value is the value of the pair
Value []byte
// Timestamp
Timestamp time.Time
}
Entry is an indexed key/value pair
type Event ¶
type Event struct {
// Type indicates the change event type
Type EventType
// Entry is the event entry
Entry *Entry
}
Event is a log change event
type GetOption ¶
type GetOption interface {
// contains filtered or unexported methods
}
GetOption is an option for the Get method
func WithDefault ¶
WithDefault sets the default value to return if the key is not present
type Log ¶
type Log interface {
primitive.Primitive
// Appends appends the given value to the end of the log
Append(ctx context.Context, value []byte) (*Entry, error)
// Get gets the value of the given index
Get(ctx context.Context, index Index, opts ...GetOption) (*Entry, error)
// FirstIndex gets the first index in the log
FirstIndex(ctx context.Context) (Index, error)
// LastIndex gets the last index in the log
LastIndex(ctx context.Context) (Index, error)
// PrevIndex gets the index before the given index
PrevIndex(ctx context.Context, index Index) (Index, error)
// NextIndex gets the index after the given index
NextIndex(ctx context.Context, index Index) (Index, error)
// FirstEntry gets the first entry in the log
FirstEntry(ctx context.Context) (*Entry, error)
// LastEntry gets the last entry in the log
LastEntry(ctx context.Context) (*Entry, error)
// PrevEntry gets the entry before the given index
PrevEntry(ctx context.Context, index Index) (*Entry, error)
// NextEntry gets the entry after the given index
NextEntry(ctx context.Context, index Index) (*Entry, error)
// Remove removes an entry from the log
Remove(ctx context.Context, index Index, opts ...RemoveOption) (*Entry, error)
// Size returns the number of entries in the log
Size(ctx context.Context) (int, error)
// Clear removes all entries from the log
Clear(ctx context.Context) error
// Entries lists the entries in the log
// This is a non-blocking method. If the method returns without error, index/value paids will be pushed on to the
// given channel and the channel will be closed once all entries have been read from the map.
Entries(ctx context.Context, ch chan<- *Entry) error
// Watch watches the log for changes
// This is a non-blocking method. If the method returns without error, log events will be pushed onto
// the given channel in the order in which they occur.
Watch(ctx context.Context, ch chan<- *Event, opts ...WatchOption) error
}
Log is a distributed log
type NotSetOption ¶
type NotSetOption struct {
}
NotSetOption is a SetOption that sets the value only if it's not already set
type RemoveOption ¶
type RemoveOption interface {
// contains filtered or unexported methods
}
RemoveOption is an option for the Remove method
type SetOption ¶
type SetOption interface {
// contains filtered or unexported methods
}
SetOption is an option for the Append method
type WatchOption ¶
type WatchOption interface {
// contains filtered or unexported methods
}
WatchOption is an option for the Watch method
func WithFilter ¶
func WithFilter(filter Filter) WatchOption
WithFilter returns a watch option that filters the watch events
func WithReplay ¶
func WithReplay() WatchOption
WithReplay returns a watch option that enables replay of watch events
Click to show internal directories.
Click to hide internal directories.