boltkv

package
v0.0.0-...-075775b Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package boltkv provides an implementation of the gRPC service KV using boltdb as a backend.

Index

Constants

View Source
const DefaultBoltBucketName = "kv"

DefaultBoltBucketName is the default bucket name used for the underlying boltdb for BoltKV.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltKV

type BoltKV struct {
	*bolt.DB
	// contains filtered or unexported fields
}

BoltKV represents a boltdb connection and implements the KVServer interface, allowing it to be used by the KV gRPC service.

func NewBoltKV

func NewBoltKV(path string, options ...BoltKVOption) (_ *BoltKV, err error)

NewBoltKV takes the path and any functional options, and constructs a new BoltKV.

func (*BoltKV) Delete

func (b *BoltKV) Delete(ctx context.Context, req *kvpb.DeleteRequest) (*emptypb.Empty, error)

Delete takes the provided DeleteRequest, containing a key to lookup, and deletes the key/value from the underlying boltdb storage. This will not check if a key is set before attempting to delete.

func (*BoltKV) Get

func (b *BoltKV) Get(ctx context.Context, req *kvpb.GetRequest) (*kvpb.GetResponse, error)

Get takes the provided GetRequest, containing a key to lookup, and returns the key and value from the underlying boltdb storage. If the key is not set, an error is returned.

func (*BoltKV) Set

func (b *BoltKV) Set(ctx context.Context, req *kvpb.SetRequest) (*emptypb.Empty, error)

Set takes the provided SetRequest, containing a key and the desired value, and sets this in the underlying boltdb storage. If a key is already set, the value will be overwritten.

type BoltKVOption

type BoltKVOption func(*BoltKV)

BoltKVOption represents the function signature for any BoltKV functional options.

func WithBucketName

func WithBucketName(bucket string) BoltKVOption

WithBucketName is a functional option for specifying a boltdb bucket name other than the default.

Jump to

Keyboard shortcuts

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