Documentation ¶
Overview ¶
Package store provides a simple and convenient data store interface for plugins to persist data along with a default filed-based leveldb implementation.
Index ¶
- func DecodeKey(rawKey string) (silo string, key string, err error)
- func EncodeKey(silo string, key string) (encKey string)
- func SiloPrefix(silo string) (prefix string)
- type BytesStorer
- type GlobalSiloStringStorer
- type LevelDB
- func (ldb *LevelDB) Close() (err error)
- func (ldb *LevelDB) Delete(key []byte) (err error)
- func (ldb *LevelDB) DeleteSiloString(silo string, key string) (err error)
- func (ldb *LevelDB) DeleteString(key string) (err error)
- func (ldb *LevelDB) Get(key []byte) (value []byte, err error)
- func (ldb *LevelDB) GetSiloString(silo string, key string) (value string, err error)
- func (ldb *LevelDB) GetString(key string) (value string, err error)
- func (ldb *LevelDB) GlobalScan() (entries map[string]map[string]string, err error)
- func (ldb *LevelDB) Put(key []byte, value []byte) (err error)
- func (ldb *LevelDB) PutSiloString(silo string, key string, value string) (err error)
- func (ldb *LevelDB) PutString(key string, value string) (err error)
- func (ldb *LevelDB) Scan() (entries map[string]string, err error)
- func (ldb *LevelDB) ScanSilo(silo string) (entries map[string]string, err error)
- type Scanner
- type SiloStringStorer
- type StringStorer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeKey ¶
EncodeKey encodes a key with the silo name and the \xda character (not a valid utf8 character)
func SiloPrefix ¶
SiloPrefix returns the prefix for a key in the given silo
Types ¶
type BytesStorer ¶
type BytesStorer interface { io.Closer Scanner Get(key []byte) (value []byte, err error) Put(key []byte, value []byte) (err error) Delete(key []byte) (err error) }
BytesStorer is implemented by any value that has the Get/Put/Delete/Scan and Closer methods on byte arrays for keys/values.
type GlobalSiloStringStorer ¶
type GlobalSiloStringStorer interface { SiloStringStorer GlobalScan() (entries map[string]map[string]string, err error) }
GlobalSiloStringStorer is implemented by any value that has all the SiloStringStorer methods and the GlobalScanSilo method
type LevelDB ¶
type LevelDB struct { Name string // contains filtered or unexported fields }
LevelDB holds a datastore name and its leveldb instance
func NewLevelDB ¶
NewLevelDB instantiates and open a new LevelDB instance backed by a leveldb database. If the leveldb database doesn't exist, one is created
func (*LevelDB) DeleteSiloString ¶
DeleteSiloString deletes an entry for a given key string in the given silo
func (*LevelDB) DeleteString ¶
DeleteString deletes an entry for a given key string
func (*LevelDB) GetSiloString ¶
GetSiloString retrieves a value associated to the key in the given silo
func (*LevelDB) GlobalScan ¶
GlobalScan returns the complete set of key/values from the database for all silos
func (*LevelDB) PutSiloString ¶
PutSiloString adds or updates a value associated to the key in the given silo
type Scanner ¶
Scanner is implemented by any value that has the Scan method returning all key/values as strings.
Since []byte aren't allowed as map keys, we use don't have an equivalent Scanner interface returning the data as bytes. For implementers, it should be easy to convert the []byte values to string with a simple string(value) conversion as strings are immutable arrays of bytes
type SiloStringStorer ¶
type SiloStringStorer interface { io.Closer GetSiloString(silo string, key string) (value string, err error) PutSiloString(silo string, key string, value string) (err error) DeleteSiloString(silo string, key string) (err error) ScanSilo(silo string) (entries map[string]string, err error) }
SiloStringStorer is implemented by any value that has the Get/Put/Delete/Scan and Closer methods on string keys/values with a silo name.
type StringStorer ¶
type StringStorer interface { io.Closer Scanner GetString(key string) (value string, err error) PutString(key string, value string) (err error) DeleteString(key string) (err error) }
StringStorer is implemented by any value that has the Get/Put/Delete/Scan and Closer methods on string keys/values.
Directories ¶
Path | Synopsis |
---|---|
Package datastoredb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface backed by the Google Cloud Datastore.
|
Package datastoredb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface backed by the Google Cloud Datastore. |
Package inmemorydb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface as an in-memory data store relying on a wrapping StringStorer for actual persistence.
|
Package inmemorydb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface as an in-memory data store relying on a wrapping StringStorer for actual persistence. |
Package mocks contains a mock of the store package interfaces
|
Package mocks contains a mock of the store package interfaces |