storage

package
v0.0.0-...-f244974 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CursorStorage

type CursorStorage interface {
	// GetCursorFor retrieves the given cursor.
	GetCursorFor(cursor *spec.Cursor) (*spec.Cursor, error)
	// SaveCursor persists the given cursor.
	SaveCursor(cursor *spec.Cursor) error
}

CursorStorage persists and retrieves cursors.

func NewCursors

func NewCursors(db LevelDB, idGenerator IDGenerator, keyGenerator KeyGenerator) CursorStorage

NewCursors ctor.

type EventStorage

type EventStorage interface {
	// Append appends the given event to the log.
	Append(event *spec.Event) (*spec.Event, error)
	// GetIterator creates an iterator pointing to the given event.
	// EventsIterator.Value() will retrieves the given event.
	GetIterator(event *spec.Event) (EventsIterator, error)
}

EventStorage persists and retrieves events.

func NewEventStorage

func NewEventStorage(db LevelDB, idGenerator IDGenerator, keyGenerator KeyGenerator, metrics Metrics) EventStorage

NewEventStorage ctor.

type EventsIterator

type EventsIterator interface {
	io.Closer

	// Value returns the current event or nil if done.
	Value() (*spec.Event, error)

	// Next moves the iterator to the next event.
	// It returns false if the iterator is exhausted.
	Next() bool
}

EventsIterator is used to iterate over events in the log

type IDGenerator

type IDGenerator interface {
	// Next generates the next sortable and collision free event ID.
	Next() string
}

IDGenerator is used to create sortable and collision free IDs for events.

func NewIDGenerator

func NewIDGenerator() IDGenerator

NewIDGenerator ctor.

type KeyGenerator

type KeyGenerator interface {
	// Cursor generates cursor key.
	Cursor(cursor *spec.Cursor) []byte
	// Event generates event key.
	Event(event *spec.Event) []byte
	// KeyToEvent reconstructs the event from the values in the given key (topic, id).
	KeyToEvent(key []byte) (*spec.Event, error)
}

KeyGenerator creates key-value store keys from domain models.

func NewKeyGenerator

func NewKeyGenerator() KeyGenerator

NewKeyGenerator ctor.

type LevelDB

type LevelDB interface {
	io.Closer
	Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)
	Write(batch *leveldb.Batch, wo *opt.WriteOptions) error
	NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
}

LevelDB interface is only used for testing purposes.

type Metrics

type Metrics interface {
	// MeasureAppendEvent measures duration and success rate of appending events
	MeasureAppendEvent(call func() (*spec.Event, error)) (*spec.Event, error)
	// MeasureGetIterator measures duration and success rate of iterator retrieval
	MeasureGetIterator(call func() (EventsIterator, error)) (EventsIterator, error)
}

Metrics provides metrics over the storage performance

func NewMetrics

func NewMetrics() Metrics

NewMetrics ctor.

Jump to

Keyboard shortcuts

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