Documentation ¶
Index ¶
- Constants
- func IsStorageAvailable(storage Type) bool
- func MakeNamespace(ns ...string) string
- func RegisterStorage(storage ServiceStorage) error
- type BoltDB
- func (b *BoltDB) Close() error
- func (b *BoltDB) Delete(namespace, key string) error
- func (b *BoltDB) DeleteNamespace(namespace string) error
- func (b *BoltDB) Init(options interface{}) error
- func (b *BoltDB) IsOpen() bool
- func (b *BoltDB) Read(namespace, key string) ([]byte, error)
- func (b *BoltDB) ReadAll(namespace string) (map[string][]byte, error)
- func (b *BoltDB) ReadAllKeys(namespace string) ([]string, error)
- func (b *BoltDB) ReadPrefix(namespace, prefix string) (map[string][]byte, error)
- func (b *BoltDB) Type() Type
- func (b *BoltDB) URI() string
- func (b *BoltDB) Update(namespace string, key string, values map[string]any) ([]byte, error)
- func (b *BoltDB) UpdateValueAndOperation(namespace, key string, updater Updater, opNamespace, opKey string, ...) (first, op []byte, err error)
- func (b *BoltDB) Write(namespace string, key string, value []byte) error
- type FilterVarsMapper
- type IncludeFunc
- type RedisDB
- func (b *RedisDB) Close() error
- func (b *RedisDB) Delete(namespace, key string) error
- func (b *RedisDB) DeleteNamespace(namespace string) error
- func (b *RedisDB) Init(i interface{}) error
- func (b *RedisDB) IsOpen() bool
- func (b *RedisDB) Read(namespace, key string) ([]byte, error)
- func (b *RedisDB) ReadAll(namespace string) (map[string][]byte, error)
- func (b *RedisDB) ReadAllKeys(namespace string) ([]string, error)
- func (b *RedisDB) ReadPrefix(namespace, prefix string) (map[string][]byte, error)
- func (b *RedisDB) Type() Type
- func (b *RedisDB) URI() string
- func (b *RedisDB) Update(namespace string, key string, values map[string]any) ([]byte, error)
- func (b *RedisDB) UpdateValueAndOperation(namespace, key string, updater Updater, opNamespace, opKey string, ...) (first, op []byte, err error)
- func (b *RedisDB) Write(namespace, key string, value []byte) error
- func (b *RedisDB) WriteMany(namespaces, keys []string, values [][]byte) error
- type ResponseSettingUpdater
- type ServiceStorage
- type Type
- type Updater
- type UpdaterWithMap
Constants ¶
const ( NamespaceKeySeparator = ":" Pong = "PONG" RedisScanBatchSize = 1000 )
const (
DBFilePrefix = "ssi-service"
)
Variables ¶
This section is empty.
Functions ¶
func IsStorageAvailable ¶
IsStorageAvailable determines whether a given storage provider is available for instantiation.
func MakeNamespace ¶
MakeNamespace takes a set of possible namespace values and combines them as a convention
func RegisterStorage ¶
func RegisterStorage(storage ServiceStorage) error
RegisterStorage registers a storage dynamically by its Type.
Types ¶
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
func (*BoltDB) DeleteNamespace ¶
func (*BoltDB) Init ¶
Init instantiates a file-based storage instance for Bolt https://github.com/boltdb/bolt
func (*BoltDB) ReadPrefix ¶
ReadPrefix does a prefix query within a namespace.
func (*BoltDB) UpdateValueAndOperation ¶
func (b *BoltDB) UpdateValueAndOperation(namespace, key string, updater Updater, opNamespace, opKey string, opUpdater ResponseSettingUpdater) (first, op []byte, err error)
UpdateValueAndOperation updates the value stored in (namespace,key) with the new values specified in the map. The updated value is then stored inside the (opNamespace, opKey), and the "done" value is set to true.
type FilterVarsMapper ¶
FilterVarsMapper is an interface that encapsulates the FilterVariablesMap method. This interface is meant to be implemented by any object that wants to include support for filtering.
type IncludeFunc ¶
type IncludeFunc func(FilterVarsMapper) (bool, error)
IncludeFunc is a function that given a mapper object, decides whether the object should be included in the result.
func NewIncludeFunc ¶
func NewIncludeFunc(filter filtering.Filter) (IncludeFunc, error)
NewIncludeFunc creates an IncludeFunc given a filter object. The result function is constructed as an evaluation of a cel program. The environment created matches standard construction of a filter. The result function runs the program evaluation on a given object that implements the FilterVarsMapper interface. Evaluation errors bubbled up so clients can decide what to do.
type RedisDB ¶
type RedisDB struct {
// contains filtered or unexported fields
}
func (*RedisDB) DeleteNamespace ¶
func (*RedisDB) ReadPrefix ¶
func (*RedisDB) UpdateValueAndOperation ¶
type ResponseSettingUpdater ¶
type ServiceStorage ¶
type ServiceStorage interface { Init(interface{}) error Type() Type URI() string IsOpen() bool Close() error Write(namespace, key string, value []byte) error Read(namespace, key string) ([]byte, error) ReadAll(namespace string) (map[string][]byte, error) ReadPrefix(namespace, prefix string) (map[string][]byte, error) ReadAllKeys(namespace string) ([]string, error) Delete(namespace, key string) error DeleteNamespace(namespace string) error Update(namespace string, key string, values map[string]any) ([]byte, error) UpdateValueAndOperation(namespace, key string, updater Updater, opNamespace, opKey string, opUpdater ResponseSettingUpdater) (first, op []byte, err error) }
ServiceStorage describes the api for storage independent of DB providers
func GetStorage ¶
func GetStorage(storageType Type) ServiceStorage
GetStorage fetches a previously registered storage by storage type.
func NewStorage ¶
func NewStorage(storageProvider Type, option interface{}) (ServiceStorage, error)
NewStorage returns the instance of the given storageProvider. If it doesn't exist, then a default implementation is created with the given option parameter.
type Type ¶
type Type string
func AvailableStorage ¶
func AvailableStorage() []Type
AvailableStorage returns the supported storage providers.
type Updater ¶
type Updater interface { Update(v []byte) ([]byte, error) // Validate runs after the data has been loaded from disk, but before the write is actually performed. Validate(v []byte) error }
Updater encapsulates the Update method, which take a slice of bytes, and updates it before it's stored in the DB.
type UpdaterWithMap ¶
UpdaterWithMap is a json map based Updater implementation. The key/values from the map are used to update the unmarshalled JSON representation of the stored data.
func NewUpdater ¶
func NewUpdater(values map[string]any) UpdaterWithMap
NewUpdater creates a new UpdaterWithMap with the given map.
func (UpdaterWithMap) Validate ¶
func (u UpdaterWithMap) Validate(_ []byte) error
Validate is a default implementation for UpdaterWithMap which does no validation. Users can pass embed UpdaterWithMap into a custom struct and redefine this method in order to have custom logic.