adapter

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidRulesLen = errors.New("invalid rule len")
)

Functions

func NewAdapter

func NewAdapter(store *BadgerStore, bucket string, builtinPolicy string) (*adapter, error)

NewAdapter creates a new adapter.

Types

type BadgerStore

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

BadgerStore provides access to Badger for Raft to store and retrieve log entries. It also provides key/value storage, and can be used as a LogStore and StableStore.

func New

func New(options Options) (*BadgerStore, error)

New uses the supplied options to open the Badger db and prepare it for use as a raft backend.

func NewBadgerStore

func NewBadgerStore(path string) (*BadgerStore, error)

NewBadgerStore takes a file path and returns a connected Raft backend.

func (BadgerStore) ForEach

func (b BadgerStore) ForEach(fn func(namespace []byte, bucket *Bucket) error) error

func (*BadgerStore) Restore

func (b *BadgerStore) Restore(reader io.Reader) error

Restore overwrites the local file

func (BadgerStore) Snapshot

func (b BadgerStore) Snapshot(writer io.Writer) error

Snapshot writes the entire database to a writer.

func (BadgerStore) Update

func (b BadgerStore) Update(fn func(tx *Tx) error) error

func (BadgerStore) View

func (b BadgerStore) View(fn func(tx *Tx) error) error

type Bucket

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

func (*Bucket) Delete

func (bucket *Bucket) Delete(key []byte) error

func (*Bucket) Exist

func (bucket *Bucket) Exist(key []byte) bool

func (*Bucket) ForEach

func (bucket *Bucket) ForEach(fn func(key []byte, value []byte) error) error

func (*Bucket) List

func (bucket *Bucket) List(cursor string, skip int64, limit int64, reverse bool) ([][]string, error)

func (*Bucket) Put

func (bucket *Bucket) Put(key []byte, value []byte) error

type CasbinRule

type CasbinRule []string

CasbinRule represents a Casbin rule line.

type IBoltStore

type IBoltStore interface {
	Restore(reader io.Reader) error
	Snapshot(writer io.Writer) error
}

type Options

type Options struct {
	// Path is the directory path to the Badger db to use.
	Path string

	// BadgerOptions contains any specific Badger options you might
	// want to specify.
	BadgerOptions *badger.Options

	// NoSync causes the database to skip fsync calls after each
	// write to the log. This is unsafe, so it should be used
	// with caution.
	NoSync bool

	// ValueLogGC enables a periodic goroutine that does a garbage
	// collection of the value log while the underlying Badger is online.
	ValueLogGC bool

	// GCInterval is the interval between conditionally running the garbage
	// collection process, based on the size of the vlog. By default, runs every 1m.
	GCInterval time.Duration

	// GCInterval is the interval between mandatory running the garbage
	// collection process. By default, runs every 10m.
	MandatoryGCInterval time.Duration

	// GCThreshold sets threshold in bytes for the vlog size to be included in the
	// garbage collection cycle. By default, 1GB.
	GCThreshold int64
}

Options contains all the configuration used to open the Badger db

type Tx

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

func (*Tx) Bucket

func (tx *Tx) Bucket(name []byte) *Bucket

func (*Tx) CreateBucketIfNotExists

func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error)

func (*Tx) View

func (tx *Tx) View(fn func(txn *badger.Txn) error) error

Jump to

Keyboard shortcuts

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