bdb

package
v0.33.28 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPathNotFound    = cerr.NewAsertoError("E20050", codes.NotFound, http.StatusNotFound, "path not found")
	ErrKeyNotFound     = cerr.NewAsertoError("E20051", codes.NotFound, http.StatusNotFound, "key not found")
	ErrKeyExists       = cerr.NewAsertoError("E20052", codes.AlreadyExists, http.StatusConflict, "key already exists")
	ErrMultipleResults = cerr.NewAsertoError("E20053", codes.FailedPrecondition, http.StatusExpectationFailed, "multiple results for singleton request")
)

Error codes returned by failures to parse an expression.

Functions

func BucketExists

func BucketExists(tx *bolt.Tx, path Path) (bool, error)

BucketExists, check if bucket path exists.

func CreateBucket

func CreateBucket(tx *bolt.Tx, path Path) (*bolt.Bucket, error)

CreateBucket, create bucket path if not exists.

func Delete

func Delete(ctx context.Context, tx *bolt.Tx, path Path, key []byte) error

func DeleteBucket

func DeleteBucket(tx *bolt.Tx, path Path) error

DeleteBucket, delete tail bucket of path provided.

func DeleteKey

func DeleteKey(tx *bolt.Tx, path Path, key []byte) error

DeleteKey, delete key and value in path specified bucket, when it exists. None existing keys will not raise an error.

func Get

func Get[T any, M Message[T]](ctx context.Context, tx *bolt.Tx, path Path, key []byte) (M, error)

func GetAny

func GetAny[T any](ctx context.Context, tx *bolt.Tx, path Path, key []byte) (*T, error)

func GetKey

func GetKey(tx *bolt.Tx, path Path, key []byte) ([]byte, error)

GetKey, get key and value from path specified bucket.

func KeyExists

func KeyExists(tx *bolt.Tx, path Path, key []byte) (bool, error)

KeyExists, check if the key exists in the path specified bucket.

func KeyPrefixExists

func KeyPrefixExists[T any, M Message[T]](ctx context.Context, tx *bolt.Tx, path Path, keyFilter []byte) (bool, error)

func List

func List[T any, M Message[T]](ctx context.Context, tx *bolt.Tx, path Path) ([]M, error)

func ListBuckets

func ListBuckets(tx *bolt.Tx, path Path) ([]string, error)

ListBuckets, returns the bucket name underneath the path.

func Scan

func Scan[T any, M Message[T]](ctx context.Context, tx *bolt.Tx, path Path, keyFilter []byte) ([]M, error)

func ScanWithFilter

func ScanWithFilter(
	ctx context.Context,
	tx *bolt.Tx,
	path Path,
	keyFilter []byte,
	valueFilter func(*dsc.RelationIdentifier) bool,
	pool graph.RelationPool,
	out *[]*dsc.RelationIdentifier,
) error

func Set

func Set[T any, M Message[T]](ctx context.Context, tx *bolt.Tx, path Path, key []byte, t M) (M, error)

func SetAny

func SetAny[T any](ctx context.Context, tx *bolt.Tx, path Path, key []byte, t *T) (*T, error)

func SetBucket

func SetBucket(tx *bolt.Tx, path Path) (*bolt.Bucket, error)

SetBucket, set bucket context to path.

func SetKey

func SetKey(tx *bolt.Tx, path Path, key, value []byte) error

SetKey, set key and value in the path specified bucket.

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) Close

func (s *BoltDB) Close()

Close closes BoltDB key-value store instance.

func (*BoltDB) Config

func (s *BoltDB) Config() *Config

func (*BoltDB) DB

func (s *BoltDB) DB() *bolt.DB

func (*BoltDB) LoadModel

func (s *BoltDB) LoadModel() error

LoadModel, reads the serialized model from the store and swaps the model instance in the cache.Cache using cache.UpdateModel.

func (*BoltDB) MC

func (s *BoltDB) MC() *cache.Cache

MC, model cache.

func (*BoltDB) Open

func (s *BoltDB) Open() error

Open BoltDB key-value store instance.

type Config

type Config struct {
	DBPath         string
	RequestTimeout time.Duration
	MaxBatchSize   int           `json:"-"` // obsolete bbolt configuration value.
	MaxBatchDelay  time.Duration `json:"-"` // obsolete bbolt configuration value.
}

type Iterator

type Iterator[T any, M Message[T]] interface {
	Next() bool       // move cursor to next element.
	RawKey() []byte   // return raw key ([]byte).
	RawValue() []byte // return raw value ([]byte).
	Key() string      // return key (string).
	Value() M         // return typed value (M).
	Delete() error    // delete element underneath cursor.
}

type Message

type Message[T any] interface {
	proto.Message
	UnmarshalVT(b []byte) error
	*T
}

type PageIterator

type PageIterator[T any, M Message[T]] struct {
	// contains filtered or unexported fields
}

func (*PageIterator[T, M]) Next

func (p *PageIterator[T, M]) Next() bool

func (*PageIterator[T, M]) NextToken

func (p *PageIterator[T, M]) NextToken() string

func (*PageIterator[T, M]) Value

func (p *PageIterator[T, M]) Value() []M

type PagedIterator

type PagedIterator[T any, M Message[T]] interface {
	Next() bool
	Value() []M
	NextToken() string
}

func NewPageIterator

func NewPageIterator[T any, M Message[T]](ctx context.Context, tx *bolt.Tx, path Path, opts ...ScanOption) (PagedIterator[T, M], error)

type Path

type Path []string
var (
	SystemPath        Path = []string{"_system"}
	ManifestPath      Path = ManifestPathV2                                         // current path
	ManifestPathV1    Path = []string{"_manifest", manifestName, manifestVersionV1} // migration path V1, OBSOLETE per migration 0.0.8
	ManifestPathV2    Path = []string{"_manifest", manifestName}                    // migration path V2
	ObjectTypesPath   Path = []string{"object_types"}                               // OBSOLETE
	PermissionsPath   Path = []string{"permissions"}                                // OBSOLETE
	RelationTypesPath Path = []string{"relation_types"}                             // OBSOLETE
	ObjectsPath       Path = []string{"objects"}                                    // objects path
	RelationsSubPath  Path = []string{"relations_sub"}                              // relation subject ordered path
	RelationsObjPath  Path = []string{"relations_obj"}                              // relation object ordered path
	MetadataKey            = []byte("metadata")                                     // _manifest.default.metadata key
	BodyKey                = []byte("body")                                         // _manifest.default.body key
	ModelKey               = []byte("model")                                        // _manifest.default.model cache key
)

type ScanArgs

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

type ScanIterator

type ScanIterator[T any, M Message[T]] struct {
	// contains filtered or unexported fields
}

func NewScanIterator

func NewScanIterator[T any, M Message[T]](ctx context.Context, tx *bolt.Tx, path Path, opts ...ScanOption) (*ScanIterator[T, M], error)

func (*ScanIterator[T, M]) Delete

func (s *ScanIterator[T, M]) Delete() error

func (*ScanIterator[T, M]) Key

func (s *ScanIterator[T, M]) Key() string

func (*ScanIterator[T, M]) Next

func (s *ScanIterator[T, M]) Next() bool

func (*ScanIterator[T, M]) RawKey

func (s *ScanIterator[T, M]) RawKey() []byte

func (*ScanIterator[T, M]) RawValue

func (s *ScanIterator[T, M]) RawValue() []byte

func (*ScanIterator[T, M]) Value

func (s *ScanIterator[T, M]) Value() M

type ScanOption

type ScanOption func(*ScanArgs)

func WithKeyFilter

func WithKeyFilter(filter []byte) ScanOption

func WithPageSize

func WithPageSize(size int32) ScanOption

func WithPageToken

func WithPageToken(token string) ScanOption

Directories

Path Synopsis
migrations

Jump to

Keyboard shortcuts

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