boltdb

package
v0.20.7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPageSize default pagination page size.
	DefaultPageSize = int32(100)
	// MinPageSize minimum pagination page size.
	MinPageSize = int32(1)
	// MaxPageSize maximum pagination page size.
	MaxPageSize = int32(100)
	// ServerSetPageSize .
	ServerSetPageSize = int32(0)
	// TotalsOnlyResultSet .
	TotalsOnlyResultSet = int32(-1)
)

Variables

View Source
var (
	ErrPathNotFound = errors.New("path not found")
	ErrKeyNotFound  = errors.New("key not found")
	ErrKeyExists    = errors.New("key already exists")
)

Error codes returned by failures to parse an expression.

Functions

func GetSessionOpts

func GetSessionOpts(opts []Opts) *sessionOpts

func PageSize

func PageSize(input int32) int32

PageSize validator.

Types

type BoltDB

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

BoltDB based key-value store.

func New

func New(config *Config, logger *zerolog.Logger) (*BoltDB, error)

func (*BoltDB) BucketExists

func (s *BoltDB) BucketExists(path []string, opts []Opts) bool

BucketExists checks if a bucket path exists.

func (*BoltDB) Close

func (s *BoltDB) Close()

Close closes BoltDB key-value store instance.

func (*BoltDB) CreateBucket

func (s *BoltDB) CreateBucket(path []string, opts []Opts) error

CreateBucket creates the bucket.

func (*BoltDB) DeleteBucket

func (s *BoltDB) DeleteBucket(path []string, opts []Opts) error

DeleteBucket delete bucket at the tail of the given path. The call does not return an error when the bucket does not exist.

func (*BoltDB) DeleteKey

func (s *BoltDB) DeleteKey(path []string, key string, opts []Opts) error

DeleteKey deletes key at given path when present. The call does not return an error when key does not exist.

func (*BoltDB) KeyExists

func (s *BoltDB) KeyExists(path []string, key string, opts []Opts) bool

KeyExists checks if a key exists at given bucket path.

func (*BoltDB) List

func (s *BoltDB) List(path []string, pageToken string, pageSize int32, opts []Opts) ([]string, [][]byte, string, int32, error)

List returns paged collection of key and value arrays.

func (*BoltDB) ListBuckets

func (s *BoltDB) ListBuckets(path []string, pageToken string, pageSize int32, opts []Opts) ([]string, string, int32, error)

ListBuckets returns pages collection of buckets.

func (*BoltDB) ListKeys

func (s *BoltDB) ListKeys(path []string, pageToken string, pageSize int32, opts []Opts) ([]string, string, int32, error)

ListKeys returns paged collection of keys.

func (*BoltDB) NextSeq

func (s *BoltDB) NextSeq(path []string, opts []Opts) (uint64, error)

Generate next ID for bucket.

func (*BoltDB) Open

func (s *BoltDB) Open() error

Open BoltDB key-value store instance.

func (*BoltDB) Read

func (s *BoltDB) Read(path []string, key string, opts []Opts) ([]byte, error)

Read value from key in bucket path.

func (*BoltDB) ReadScan

func (s *BoltDB) ReadScan(path []string, prefix string, opts []Opts) ([]string, [][]byte, error)

ReadScan returns list of key-value pairs which match the scan prefix filter.

func (*BoltDB) ReadTxOpts

func (s *BoltDB) ReadTxOpts() (Opts, func() error, error)

func (*BoltDB) Write

func (s *BoltDB) Write(path []string, key string, value []byte, opts []Opts) error

Write write value at key for given path.

func (*BoltDB) WriteTxOpts

func (s *BoltDB) WriteTxOpts() (Opts, func(err error) error, error)

type Config

type Config struct {
	DBPath         string
	RequestTimeout time.Duration
}

type Opts

type Opts func(interface{})

func WithSession

func WithSession(id string) Opts

func WithTx

func WithTx(tx *bolt.Tx) Opts

type PaginationOpts

type PaginationOpts struct {
	Token    string
	PageSize int32
}

type PaginationResult

type PaginationResult struct {
	NextToken string
	TotalSize int32
}

Jump to

Keyboard shortcuts

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