store

package
v0.0.0-...-2af415a Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Timeout = time.Second * 30

Timeout defines the default database dial timeout.

Variables

View Source
var (
	ErrWatchCanceled = errors.New("watch canceled by the server")
	ErrWatchClosed   = errors.New("watch closed by the client")
)
View Source
var ErrKeyNotFound = errors.New("key not found")

Functions

This section is empty.

Types

type Event

type Event struct {
	Type    EventType
	Val     []byte
	Version int64
}

Event is a database agnostic event object.

type EventType

type EventType string
const (
	EventAdded    EventType = "ADDED"
	EventModified EventType = "MODIFIED"
	EventDeleted  EventType = "DELETED"
)

type Storer

type Storer interface {
	Put(string, []byte) (int64, error)
	Get(string) ([]byte, int64, error)
	GetKeysWithPrefix(string) ([]string, error)
	Delete(string) error
	Watcher(context.Context, string) Watcher
}

Storer defines behaviour all storage implementations must have.

func New

func New(ends []string) (Storer, error)

New returns a new storage implememtation.

type Watcher

type Watcher interface {
	// Start starts watching specified resource.
	Start()
	// Stop stops the watcher.
	Stop()
	// EventChan returns events as they occur.
	EventChan() <-chan *Event
	// ErrChan returns an error, if any. The watcher is terminated on
	// receiving an error.
	ErrChan() <-chan error
}

Watcher defines behaviour all watchers must have.

Jump to

Keyboard shortcuts

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