log

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

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

func (Entry) String

func (kv Entry) String() string

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 EventType

type EventType string

EventType is the type of a log event

const (
	// EventNone indicates the event is not a change event
	EventNone EventType = ""

	// EventAppended indicates an entry was appended to the log
	EventAppended EventType = "appended"

	// EventRemoved indicates an entry was removed from the log
	EventRemoved EventType = "removed"
)

type Filter

type Filter struct {
	Index Index
}

Filter is a watch filter configuration

type GetOption

type GetOption interface {
	// contains filtered or unexported methods
}

GetOption is an option for the Get method

func WithDefault

func WithDefault(def []byte) GetOption

WithDefault sets the default value to return if the key is not present

type Index

type Index uint64

Index is the index of an entry

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

func New

func New(ctx context.Context, name primitive.Name, partitions []*primitive.Session) (Log, error)

New creates a new log primitive

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

func IfNotSet

func IfNotSet() SetOption

IfNotSet sets the value if the entry is not yet set

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

Jump to

Keyboard shortcuts

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