Documentation
¶
Overview ¶
Package legacy stores previous, unsupported versions of the backend and is used for migrations
Index ¶
- Constants
- func AnyTTL(clock clockwork.Clock, times ...time.Time) time.Duration
- func Import(ctx context.Context, importer Importer, newExporter NewExporterFunc) error
- func TTL(clock clockwork.Clock, t time.Time) time.Duration
- func ValidateLockTTL(ttl time.Duration) error
- type Backend
- type Config
- type Exporter
- type Importer
- type Item
- type Items
- type NameFunc
- type NewExporterFunc
- type NewFunc
- type OpConfig
- type OpOption
- type Params
Constants ¶
Forever means that object TTL will not expire unless deleted
Variables ¶
This section is empty.
Functions ¶
func AnyTTL ¶
AnyTTL returns TTL if any of the suplied times pass expiry time otherwise returns forever
func Import ¶
func Import(ctx context.Context, importer Importer, newExporter NewExporterFunc) error
Import imports backend data into importer unless importer has already imported data. If Importer has no imported data yet, exporter will not be initialized. This function can be called many times on the same importer. Importer will be closed if import has failed.
func TTL ¶
TTL converts time to TTL from current time supplied by provider, if t is zero, returns forever
func ValidateLockTTL ¶
ValidateLockTTL helper allows all backends to validate lock TTL parameter
Types ¶
type Backend ¶
type Backend interface {
// GetKeys returns a list of keys for a given path
GetKeys(bucket []string) ([]string, error)
// GetItems returns a list of items (key value pairs) for a bucket.
GetItems(bucket []string, opts ...OpOption) ([]Item, error)
// CreateVal creates value with a given TTL and key in the bucket
// if the value already exists, it must return trace.AlreadyExistsError
CreateVal(bucket []string, key string, val []byte, ttl time.Duration) error
// UpsertVal updates or inserts value with a given TTL into a bucket
// ForeverTTL for no TTL
UpsertVal(bucket []string, key string, val []byte, ttl time.Duration) error
// UpsertItems updates or inserts all passed in backend.Items (with a TTL)
// into the given bucket.
UpsertItems(bucket []string, items []Item) error
// GetVal return a value for a given key in the bucket
GetVal(path []string, key string) ([]byte, error)
// CompareAndSwapVal compares and swaps values in atomic operation,
// succeeds if prevVal matches the value stored in the database,
// requires prevVal as a non-empty value. Returns trace.CompareFailed
// in case if value did not match.
CompareAndSwapVal(bucket []string, key string, val []byte, prevVal []byte, ttl time.Duration) error
// DeleteKey deletes a key in a bucket
DeleteKey(bucket []string, key string) error
// DeleteBucket deletes the bucket by a given path
DeleteBucket(path []string, bkt string) error
// AcquireLock grabs a lock that will be released automatically in TTL
AcquireLock(token string, ttl time.Duration) error
// ReleaseLock forces lock release before TTL
ReleaseLock(token string) error
// Close releases the resources taken up by this backend
Close() error
// Clock returns clock used by this backend
Clock() clockwork.Clock
}
Backend implements abstraction over local or remote storage backend
Storage is modeled after BoltDB:
- bucket is a slice []string{"a", "b"}
- buckets contain key value pairs
type Config ¶
type Config struct {
// Type can be "bolt" or "etcd" or "dynamodb"
Type string `yaml:"type,omitempty"`
// Params is a generic key/value property bag which allows arbitrary
// falues to be passed to backend
Params Params `yaml:",inline"`
}
Config is used for 'storage' config section. It's a combination of values for various backends: 'boltdb', 'etcd', 'filesystem' and 'dynamodb'
type Importer ¶
type Importer interface {
// Import imports elements, makes sure elements are imported only once
// returns trace.AlreadyExists if elements have been imported
Import(ctx context.Context, items []backend.Item) error
// Imported returns true if backend already imported data from another backend
Imported(ctx context.Context) (bool, error)
// Close closes importer
Close() error
}
Importer specifies methods for importing data from legacy backends
type Item ¶
type Item struct {
// FullPath is set to full path
FullPath string
// Key is an item key.
Key string
// Value is an item value.
Value []byte
// TTL is the expire time for the item.
TTL time.Duration
}
Item is a pair of key and value.
type NameFunc ¶
type NameFunc func() string
NameFunc type defines a function type which every backend must implement to return its name
type NewExporterFunc ¶
NewExporterFunc returns new exporter
type NewFunc ¶
NewFunc type defines a function type which every backend must implement to instantiate itself
type OpConfig ¶
type OpConfig struct {
// Recursive triggers recursive get
Recursive bool
// KeysOnly fetches only keys
KeysOnly bool
}
OpConfig contains operation config
func CollectOptions ¶
CollectOptions collects all options from functional arg and returns config
Directories
¶
| Path | Synopsis |
|---|---|
|
Package boltbk implements BoltDB backed backend for standalone instances This is a legacy backend which only exists for backward compatibility purposes
|
Package boltbk implements BoltDB backed backend for standalone instances This is a legacy backend which only exists for backward compatibility purposes |
|
dir package implements backend.Backend interface using the filesystem.
|
dir package implements backend.Backend interface using the filesystem. |
|
Package test contains a backend acceptance test suite that is backend implementation independent each backend will use the suite to test itself
|
Package test contains a backend acceptance test suite that is backend implementation independent each backend will use the suite to test itself |