dir

package
v4.0.4-debug.1+incompa... Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

dir package implements backend.Backend interface using the filesystem. The filesystem needs to be POSIX compliant and support BSD locks (flock).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetName

func GetName() string

GetName returns the name of this backend.

Types

type Backend

type Backend struct {
	// InternalClock is a test-friendly source of current time
	InternalClock clockwork.Clock
	// contains filtered or unexported fields
}

Backend implements backend.Backend interface using a regular POSIX-style filesystem

func New

func New(params legacy.Params) (*Backend, error)

New creates a new instance of a directory based backend that implements backend.Backend.

func (*Backend) AcquireLock

func (bk *Backend) AcquireLock(token string, ttl time.Duration) (err error)

AcquireLock grabs a lock that will be released automatically in TTL.

func (*Backend) Clock

func (b *Backend) Clock() clockwork.Clock

Clock returns the clock used by this backend.

func (*Backend) Close

func (bk *Backend) Close() error

Close releases the resources taken up the backend.

func (*Backend) CompareAndSwapVal

func (bk *Backend) CompareAndSwapVal(bucket []string, key string, val []byte, prevVal []byte, ttl time.Duration) error

CompareAndSwapVal compares and swap values in atomic operation

func (*Backend) CreateVal

func (bk *Backend) CreateVal(bucket []string, key string, val []byte, ttl time.Duration) error

CreateVal creates a key/value pair with the given TTL in the bucket. If the key already exists in the bucket, trace.AlreadyExists is returned.

func (*Backend) DeleteBucket

func (bk *Backend) DeleteBucket(parent []string, bucket string) error

DeleteBucket deletes the bucket by a given path.

func (*Backend) DeleteKey

func (bk *Backend) DeleteKey(bucket []string, key string) error

DeleteKey deletes a key in a bucket.

func (*Backend) Export

func (bk *Backend) Export() ([]backend.Item, error)

Export exports all items from the backend in new backend Items

func (*Backend) GetItems

func (bk *Backend) GetItems(bucket []string, opts ...legacy.OpOption) ([]legacy.Item, error)

GetItems returns all items (key/value pairs) in a given bucket.

func (*Backend) GetKeys

func (bk *Backend) GetKeys(bucket []string) ([]string, error)

GetKeys returns a list of keys for a given bucket.

func (*Backend) GetVal

func (bk *Backend) GetVal(bucket []string, key string) ([]byte, error)

GetVal return a value for a given key in the bucket

func (*Backend) ReleaseLock

func (bk *Backend) ReleaseLock(token string) (err error)

ReleaseLock forces lock release before TTL.

func (*Backend) UpsertItems

func (bk *Backend) UpsertItems(bucket []string, newItems []legacy.Item) error

UpsertItems inserts (or updates if it already exists) all passed in legacy.Items with the given TTL.

func (*Backend) UpsertVal

func (bk *Backend) UpsertVal(bucket []string, key string, val []byte, ttl time.Duration) error

UpsertVal inserts (or updates if it already exists) the value for a key with the given TTL.

Jump to

Keyboard shortcuts

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