Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingPath = errors.New("bbolt: path is missing from config") ErrCantWriteToPath = errors.New("bbolt: can't write to path") )
var (
ErrNotExists = errors.New("bbolt: value does not exist in store")
)
Sentinel error value used for testing and in admin-visible error messages.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Path is the filesystem path of the database. The folder must be writable to Anubis.
Path string `json:"path"`
}
Config is the bbolt storage backend configuration.
type Factory ¶
type Factory struct{}
Factory builds new instances of the bbolt storage backend according to configuration passed via a json.RawMessage.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements store.Interface backed by bbolt1.
In essence, bbolt is a hierarchical key/value store with a twist: every value needs to belong to a bucket. Buckets can contain an infinite number of buckets. As such, Anubis nests values in buckets. Each value in the store is given its own bucket with two keys:
1. data - The raw data, usually in JSON 2. expiry - The expiry time formatted as a time.RFC3339Nano timestamp string
When Anubis stores a new bit of data, it creates a new bucket for that value. This allows the cleanup phase to iterate over every bucket in the database and only scan the expiry times without having to decode the entire record.
bbolt is not suitable for environments where multiple instance of Anubis need to read from and write to the same backend store. For that, use the valkey storage backend.
func (*Store) Get ¶
Get a value from the datastore.
Because each value is stored in its own bucket with data and expiry keys, two get operations are required:
1. Get the expiry key, parse as time.RFC3339Nano. If the key has expired, run deletion in the background and return a "key not found" error. 2. Get the data key, copy into the result byteslice, return it.