kv

package
v0.0.0-...-e6657e5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	Name() string
	Get(ctx context.Context, key string) ([]byte, error)
	Set(ctx context.Context, key string, value []byte) error
	Delete(ctx context.Context, key string) error
	WatchAll(ctx context.Context) (Watcher, error)
	Unwatch(w Watcher)
	ListKeys(ctx context.Context) ([]string, error)
}

type Client

type Client interface {
	Bucket(ctx context.Context, name string) (Bucket, error)
}

type JSONBucket

type JSONBucket struct {
	BucketName string            `json:"name"`
	Data       map[string][]byte `json:"data"`
	// contains filtered or unexported fields
}

func (*JSONBucket) Delete

func (b *JSONBucket) Delete(ctx context.Context, key string) error

func (*JSONBucket) Get

func (b *JSONBucket) Get(ctx context.Context, key string) ([]byte, error)

func (*JSONBucket) ListKeys

func (b *JSONBucket) ListKeys(ctx context.Context) ([]string, error)

func (*JSONBucket) Name

func (b *JSONBucket) Name() string

func (*JSONBucket) Set

func (b *JSONBucket) Set(ctx context.Context, key string, value []byte) error

func (*JSONBucket) Unwatch

func (b *JSONBucket) Unwatch(w Watcher)

func (*JSONBucket) WatchAll

func (b *JSONBucket) WatchAll(ctx context.Context) (Watcher, error)

type JSONClient

type JSONClient struct {
	// contains filtered or unexported fields
}

func NewJSONClient

func NewJSONClient(store storage.Storage, fileName string) (*JSONClient, error)

func (*JSONClient) Bucket

func (j *JSONClient) Bucket(ctx context.Context, name string) (Bucket, error)

type JSONWatcher

type JSONWatcher struct {
	// contains filtered or unexported fields
}

func (*JSONWatcher) Changes

func (j *JSONWatcher) Changes() <-chan *Value

func (*JSONWatcher) Unwatch

func (j *JSONWatcher) Unwatch()

type Logged

type Logged struct {
	// contains filtered or unexported fields
}

func WithLogger

func WithLogger(c Client) *Logged

func (*Logged) Bucket

func (l *Logged) Bucket(ctx context.Context, name string) (Bucket, error)

type LoggedBucket

type LoggedBucket struct {
	// contains filtered or unexported fields
}

func (*LoggedBucket) Delete

func (b *LoggedBucket) Delete(ctx context.Context, key string) error

func (*LoggedBucket) Get

func (b *LoggedBucket) Get(ctx context.Context, key string) ([]byte, error)

func (*LoggedBucket) ListKeys

func (b *LoggedBucket) ListKeys(ctx context.Context) ([]string, error)

func (*LoggedBucket) Name

func (b *LoggedBucket) Name() string

func (*LoggedBucket) Set

func (b *LoggedBucket) Set(ctx context.Context, key string, value []byte) error

func (*LoggedBucket) Unwatch

func (b *LoggedBucket) Unwatch(w Watcher)

func (*LoggedBucket) WatchAll

func (b *LoggedBucket) WatchAll(ctx context.Context) (Watcher, error)

type LoggedWatcher

type LoggedWatcher struct {
	// contains filtered or unexported fields
}

func (*LoggedWatcher) Changes

func (w *LoggedWatcher) Changes() <-chan *Value

func (*LoggedWatcher) Unwatch

func (w *LoggedWatcher) Unwatch()

type NATSBucket

type NATSBucket struct {
	// contains filtered or unexported fields
}

func (*NATSBucket) Delete

func (b *NATSBucket) Delete(ctx context.Context, key string) error

func (*NATSBucket) Get

func (b *NATSBucket) Get(ctx context.Context, key string) ([]byte, error)

func (*NATSBucket) ListKeys

func (b *NATSBucket) ListKeys(ctx context.Context) ([]string, error)

func (*NATSBucket) Name

func (b *NATSBucket) Name() string

func (*NATSBucket) Set

func (b *NATSBucket) Set(ctx context.Context, key string, value []byte) error

func (*NATSBucket) Unwatch

func (b *NATSBucket) Unwatch(w Watcher)

func (*NATSBucket) WatchAll

func (b *NATSBucket) WatchAll(ctx context.Context) (Watcher, error)

type NATSClient

type NATSClient struct {
	// contains filtered or unexported fields
}

func NewNATSClient

func NewNATSClient(js jetstream.JetStream) *NATSClient

func (*NATSClient) Bucket

func (n *NATSClient) Bucket(ctx context.Context, name string) (Bucket, error)

type NATSOptions

type NATSOptions struct {
	URL string `json:"url"`
}

type NATSWatcher

type NATSWatcher struct {
	// contains filtered or unexported fields
}

func (*NATSWatcher) Changes

func (w *NATSWatcher) Changes() <-chan *Value

func (*NATSWatcher) Unwatch

func (w *NATSWatcher) Unwatch()

type Operation

type Operation int
const (
	Put Operation = iota
	Delete
)

func (Operation) String

func (o Operation) String() string

type Value

type Value struct {
	Key       string
	Value     []byte
	Operation Operation
}

type Watcher

type Watcher interface {
	Changes() <-chan *Value
	Unwatch()
}

Jump to

Keyboard shortcuts

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