Documentation
¶
Index ¶
- Constants
- Variables
- func Traverse(t *bolt.Tx, buckets []string) (*bolt.Bucket, error)
- func TraverseCreate(t *bolt.Tx, buckets []string) (*bolt.Bucket, error)
- type CapybaraDB
- func (cdb *CapybaraDB) ClaimLock(key, owner string, pttl *time.Duration) (*pb.Lock, bool, error)
- func (c *CapybaraDB) Close() error
- func (cdb *CapybaraDB) Delete(buckets []string, key string) error
- func (cdb *CapybaraDB) DeletePath(path, sep string) error
- func (cdb *CapybaraDB) Get(buckets []string, key string) ([]byte, error)
- func (cdb *CapybaraDB) GetPath(path, sep string) ([]byte, error)
- func (cdb *CapybaraDB) Put(buckets []string, key string, value []byte) error
- func (cdb *CapybaraDB) PutPath(path, sep string, value []byte) error
- func (cdb *CapybaraDB) ReleaseLock(key, owner string) error
Constants ¶
const (
// LocksBucket is the default bucket used to store the locks.
LocksBucket = "_locks"
)
Variables ¶
var ( // ErrBucketNotFound is returned when a specific bucket can't be found. ErrBucketNotFound = errors.New("bucket not found") // ErrNoBucket is returned when trying to put, get or delete a key with no // bucket. ErrNoBucket = errors.New("no bucket provided") // ErrIncompatibleValue is returned when attempting to put/delete/get a key // that is actually a bucket or a bucket that is actually a key. Basically // that means the bucket path + key is invalid. ErrIncompatibleValue = errors.New("incompatible value") )
var ErrLockNotFound = errors.New("lock not found")
ErrLockNotFound is the error returned when a lock can't be found.
var ErrLocksBucketNotFound = errors.New("locks bucket not found")
ErrLocksBucketNotFound is the error returned when the bucket isn't found.
var ErrNotOwner = errors.New("not the lock owner")
ErrNotOwner is the error returned when ownership of the lock doesn't match.
Functions ¶
Types ¶
type CapybaraDB ¶
type CapybaraDB struct {
// contains filtered or unexported fields
}
CapybaraDB is the struct representing a capybara database.
func NewCapybaraDB ¶
NewCapybaraDB creates a new instance of CapybaraDB.
func (*CapybaraDB) ClaimLock ¶
ClaimLock can be used to claim a lock. If the lock is already owned, it will send back the lock's details. If the service creating this claim is the same as the owner (defined by the owner parameter), the lock's expiration date is delayed.
func (*CapybaraDB) Delete ¶
func (cdb *CapybaraDB) Delete(buckets []string, key string) error
Delete will attempt to delete the provided key in the given bucket path. An error is returned if the operation can't complete.
func (*CapybaraDB) DeletePath ¶
func (cdb *CapybaraDB) DeletePath(path, sep string) error
DeletePath will delete a key given a full path to the key and a separator.
func (*CapybaraDB) Get ¶
func (cdb *CapybaraDB) Get(buckets []string, key string) ([]byte, error)
Get returns the raw value of they key stored in the given bucket path.
func (*CapybaraDB) GetPath ¶
func (cdb *CapybaraDB) GetPath(path, sep string) ([]byte, error)
GetPath will return the path.
func (*CapybaraDB) Put ¶
func (cdb *CapybaraDB) Put(buckets []string, key string, value []byte) error
Put puts a value at the given key in the given bucket. The buckets will be created on the fly if need be. An error will be returned if no bucket is provided or if the path is invalid.
func (*CapybaraDB) PutPath ¶
func (cdb *CapybaraDB) PutPath(path, sep string, value []byte) error
PutPath puts a value at the given path. The buckets will be created on the fly if need be. An error will be returned if no bucket is provided or if the path is invalid.
func (*CapybaraDB) ReleaseLock ¶
func (cdb *CapybaraDB) ReleaseLock(key, owner string) error
ReleaseLock can be used to release (or free) a lock.