Documentation
¶
Overview ¶
Package storage is a generated GoMock package.
Index ¶
- Variables
- func AddDIDtoSQLDB(t testing.TB, db *gorm.DB, dids ...did.DID)
- func CreateTestBBoltStore(tb testing.TB, filePath string) stoabs.KVStore
- type BBoltBackupConfig
- type BBoltConfig
- type Class
- type Config
- type Engine
- type InMemorySessionDatabase
- type KVBackedLeiaStore
- type LeiaBackupConfiguration
- type MemcachedConfig
- type MemcachedSessionDatabase
- type MockEngine
- func (m *MockEngine) Configure(config core.ServerConfig) error
- func (m *MockEngine) EXPECT() *MockEngineMockRecorder
- func (m *MockEngine) GetProvider(moduleName string) Provider
- func (m *MockEngine) GetSQLDatabase() *gorm.DB
- func (m *MockEngine) GetSessionDatabase() SessionDatabase
- func (m *MockEngine) Shutdown() error
- func (m *MockEngine) Start() error
- type MockEngineMockRecorder
- func (mr *MockEngineMockRecorder) Configure(config any) *gomock.Call
- func (mr *MockEngineMockRecorder) GetProvider(moduleName any) *gomock.Call
- func (mr *MockEngineMockRecorder) GetSQLDatabase() *gomock.Call
- func (mr *MockEngineMockRecorder) GetSessionDatabase() *gomock.Call
- func (mr *MockEngineMockRecorder) Shutdown() *gomock.Call
- func (mr *MockEngineMockRecorder) Start() *gomock.Call
- type MockProvider
- type MockProviderMockRecorder
- type MockSessionDatabase
- type MockSessionDatabaseMockRecorder
- type MockSessionStore
- func (m *MockSessionStore) Delete(key string) error
- func (m *MockSessionStore) EXPECT() *MockSessionStoreMockRecorder
- func (m *MockSessionStore) Exists(key string) bool
- func (m *MockSessionStore) Get(key string, target any) error
- func (m *MockSessionStore) GetAndDelete(key string, target any) error
- func (m *MockSessionStore) Put(key string, value any, options ...SessionOption) error
- type MockSessionStoreMockRecorder
- func (mr *MockSessionStoreMockRecorder) Delete(key any) *gomock.Call
- func (mr *MockSessionStoreMockRecorder) Exists(key any) *gomock.Call
- func (mr *MockSessionStoreMockRecorder) Get(key, target any) *gomock.Call
- func (mr *MockSessionStoreMockRecorder) GetAndDelete(key, target any) *gomock.Call
- func (mr *MockSessionStoreMockRecorder) Put(key, value any, options ...any) *gomock.Call
- type Mockdatabase
- type MockdatabaseMockRecorder
- type Provider
- type RDSIAMConfig
- type RedisConfig
- type RedisSentinelConfig
- type RedisTLSConfig
- type SQLConfig
- type SessionConfig
- type SessionDatabase
- type SessionOption
- type SessionStore
- type SessionStoreImpl
- func (s SessionStoreImpl[T]) Delete(key string) error
- func (s SessionStoreImpl[T]) Exists(key string) bool
- func (s SessionStoreImpl[T]) Get(key string, target interface{}) error
- func (s SessionStoreImpl[T]) GetAndDelete(key string, target interface{}) error
- func (s SessionStoreImpl[T]) Put(key string, value interface{}, options ...SessionOption) error
- type StaticKVStoreProvider
- type StringOrBytes
- type TransactionKey
Constants ¶
This section is empty.
Variables ¶
var DefaultBBoltOptions = []stoabs.Option{ stoabs.WithLockAcquireTimeout(lockAcquireTimeout), }
var ErrNotFound = errors.New("not found")
Functions ¶
Types ¶
type BBoltBackupConfig ¶
type BBoltBackupConfig struct {
// Directory specifies the directory in which the BBolt backup should be written.
Directory string `koanf:"directory"`
// Interval specifies the time between backups.
Interval time.Duration `koanf:"interval"`
}
BBoltBackupConfig specifies config for BBolt database backups.
func (BBoltBackupConfig) Enabled ¶
func (b BBoltBackupConfig) Enabled() bool
Enabled returns whether backups are enabled for BBolt.
type BBoltConfig ¶
type BBoltConfig struct {
// Backup specifies backup config for the database.
Backup BBoltBackupConfig `koanf:"backup"`
// LockTimeout specifies the maximum time to wait for acquiring a lock on the database before giving up and returning an error.
LockTimeout time.Duration `koanf:"locktimeout"`
}
BBoltConfig specifies config for BBolt databases.
type Config ¶
type Config struct {
BBolt BBoltConfig `koanf:"bbolt"`
Redis RedisConfig `koanf:"redis"`
SQL SQLConfig `koanf:"sql"`
Session SessionConfig `koanf:"session"`
}
Config specifies config for the storage engine.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default configuration for the module.
type Engine ¶
type Engine interface {
core.Engine
core.Configurable
core.Runnable
// GetProvider returns the Provider for the given module.
GetProvider(moduleName string) Provider
// GetSessionDatabase returns the SessionDatabase
GetSessionDatabase() SessionDatabase
// GetSQLDatabase returns the SQL database.
GetSQLDatabase() *gorm.DB
}
Engine defines the interface for the storage engine.
func NewTestStorageEngine ¶
type InMemorySessionDatabase ¶
type InMemorySessionDatabase struct {
// contains filtered or unexported fields
}
InMemorySessionDatabase is an in memory database that holds session data on a KV basis. Keys could be access tokens, nonce's, authorization codes, etc. All entries are stored with a TTL, so they will be removed automatically.
func NewInMemorySessionDatabase ¶
func NewInMemorySessionDatabase() *InMemorySessionDatabase
NewInMemorySessionDatabase creates a new in memory session database.
func NewTestInMemorySessionDatabase ¶
func NewTestInMemorySessionDatabase(t *testing.T) *InMemorySessionDatabase
func (*InMemorySessionDatabase) Close ¶
func (s *InMemorySessionDatabase) Close()
func (*InMemorySessionDatabase) GetStore ¶
func (s *InMemorySessionDatabase) GetStore(ttl time.Duration, keys ...string) SessionStore
type KVBackedLeiaStore ¶
type KVBackedLeiaStore interface {
leia.Store
// AddConfiguration adds a configuration for a collection to the store.
// This is needed to know the kind of collection, the backup shelf name and the iterate query to fetch the documents.
AddConfiguration(config LeiaBackupConfiguration)
// HandleRestore migrates the data from the backup store to the leia.Store if needed.
// It's up to the caller to create the indices on the leia.Collections first before calling this method.
HandleRestore() error
}
KVBackedLeiaStore is a wrapper interface for a leia.Store that uses a stoabs.KVStore as backup for any documents added.
func NewKVBackedLeiaStore ¶
NewKVBackedLeiaStore creates a wrapper around a leia.Store that uses a stoabs.KVStore as backup. Write operations (add/delete/update) are first performed on the backup store, then on the leia store. The backup store is not closed when Close is called. The leia.Store is closed when Close is called.
type LeiaBackupConfiguration ¶
type LeiaBackupConfiguration struct {
// CollectionName is the name of the collection in the leia.Store.
CollectionName string
CollectionType leia.CollectionType
// BackupShelf is the name of the shelf in the backup store.
BackupShelf string
// SearchQuery is used to fill the backup shelf if not present.
SearchQuery leia.QueryPath
}
LeiaBackupConfiguration contains the configuration for a collection that is backed by a stoabs.KVStore.
type MemcachedConfig ¶
type MemcachedConfig struct {
Address []string `koanf:"address"`
}
MemcachedConfig holds the configuration for the memcached storage.
type MemcachedSessionDatabase ¶
type MemcachedSessionDatabase struct {
// contains filtered or unexported fields
}
func NewMemcachedSessionDatabase ¶
func NewMemcachedSessionDatabase(client *memcache.Client) *MemcachedSessionDatabase
NewMemcachedSessionDatabase creates a new MemcachedSessionDatabase using an initialized memcache.Client.
func (MemcachedSessionDatabase) Close ¶
func (s MemcachedSessionDatabase) Close()
func (MemcachedSessionDatabase) GetStore ¶
func (s MemcachedSessionDatabase) GetStore(ttl time.Duration, keys ...string) SessionStore
type MockEngine ¶
type MockEngine struct {
// contains filtered or unexported fields
}
MockEngine is a mock of Engine interface.
func NewMockEngine ¶
func NewMockEngine(ctrl *gomock.Controller) *MockEngine
NewMockEngine creates a new mock instance.
func (*MockEngine) Configure ¶
func (m *MockEngine) Configure(config core.ServerConfig) error
Configure mocks base method.
func (*MockEngine) EXPECT ¶
func (m *MockEngine) EXPECT() *MockEngineMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockEngine) GetProvider ¶
func (m *MockEngine) GetProvider(moduleName string) Provider
GetProvider mocks base method.
func (*MockEngine) GetSQLDatabase ¶
func (m *MockEngine) GetSQLDatabase() *gorm.DB
GetSQLDatabase mocks base method.
func (*MockEngine) GetSessionDatabase ¶
func (m *MockEngine) GetSessionDatabase() SessionDatabase
GetSessionDatabase mocks base method.
type MockEngineMockRecorder ¶
type MockEngineMockRecorder struct {
// contains filtered or unexported fields
}
MockEngineMockRecorder is the mock recorder for MockEngine.
func (*MockEngineMockRecorder) Configure ¶
func (mr *MockEngineMockRecorder) Configure(config any) *gomock.Call
Configure indicates an expected call of Configure.
func (*MockEngineMockRecorder) GetProvider ¶
func (mr *MockEngineMockRecorder) GetProvider(moduleName any) *gomock.Call
GetProvider indicates an expected call of GetProvider.
func (*MockEngineMockRecorder) GetSQLDatabase ¶
func (mr *MockEngineMockRecorder) GetSQLDatabase() *gomock.Call
GetSQLDatabase indicates an expected call of GetSQLDatabase.
func (*MockEngineMockRecorder) GetSessionDatabase ¶
func (mr *MockEngineMockRecorder) GetSessionDatabase() *gomock.Call
GetSessionDatabase indicates an expected call of GetSessionDatabase.
func (*MockEngineMockRecorder) Shutdown ¶
func (mr *MockEngineMockRecorder) Shutdown() *gomock.Call
Shutdown indicates an expected call of Shutdown.
func (*MockEngineMockRecorder) Start ¶
func (mr *MockEngineMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start.
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
MockProvider is a mock of Provider interface.
func NewMockProvider ¶
func NewMockProvider(ctrl *gomock.Controller) *MockProvider
NewMockProvider creates a new mock instance.
func (*MockProvider) EXPECT ¶
func (m *MockProvider) EXPECT() *MockProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockProvider) GetKVStore ¶
GetKVStore mocks base method.
type MockProviderMockRecorder ¶
type MockProviderMockRecorder struct {
// contains filtered or unexported fields
}
MockProviderMockRecorder is the mock recorder for MockProvider.
func (*MockProviderMockRecorder) GetKVStore ¶
func (mr *MockProviderMockRecorder) GetKVStore(name, class any) *gomock.Call
GetKVStore indicates an expected call of GetKVStore.
type MockSessionDatabase ¶
type MockSessionDatabase struct {
// contains filtered or unexported fields
}
MockSessionDatabase is a mock of SessionDatabase interface.
func NewMockSessionDatabase ¶
func NewMockSessionDatabase(ctrl *gomock.Controller) *MockSessionDatabase
NewMockSessionDatabase creates a new mock instance.
func (*MockSessionDatabase) EXPECT ¶
func (m *MockSessionDatabase) EXPECT() *MockSessionDatabaseMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSessionDatabase) GetStore ¶
func (m *MockSessionDatabase) GetStore(ttl time.Duration, keys ...string) SessionStore
GetStore mocks base method.
type MockSessionDatabaseMockRecorder ¶
type MockSessionDatabaseMockRecorder struct {
// contains filtered or unexported fields
}
MockSessionDatabaseMockRecorder is the mock recorder for MockSessionDatabase.
func (*MockSessionDatabaseMockRecorder) Close ¶
func (mr *MockSessionDatabaseMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
type MockSessionStore ¶
type MockSessionStore struct {
// contains filtered or unexported fields
}
MockSessionStore is a mock of SessionStore interface.
func NewMockSessionStore ¶
func NewMockSessionStore(ctrl *gomock.Controller) *MockSessionStore
NewMockSessionStore creates a new mock instance.
func (*MockSessionStore) Delete ¶
func (m *MockSessionStore) Delete(key string) error
Delete mocks base method.
func (*MockSessionStore) EXPECT ¶
func (m *MockSessionStore) EXPECT() *MockSessionStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSessionStore) Exists ¶
func (m *MockSessionStore) Exists(key string) bool
Exists mocks base method.
func (*MockSessionStore) Get ¶
func (m *MockSessionStore) Get(key string, target any) error
Get mocks base method.
func (*MockSessionStore) GetAndDelete ¶
func (m *MockSessionStore) GetAndDelete(key string, target any) error
GetAndDelete mocks base method.
func (*MockSessionStore) Put ¶
func (m *MockSessionStore) Put(key string, value any, options ...SessionOption) error
Put mocks base method.
type MockSessionStoreMockRecorder ¶
type MockSessionStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockSessionStoreMockRecorder is the mock recorder for MockSessionStore.
func (*MockSessionStoreMockRecorder) Delete ¶
func (mr *MockSessionStoreMockRecorder) Delete(key any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockSessionStoreMockRecorder) Exists ¶
func (mr *MockSessionStoreMockRecorder) Exists(key any) *gomock.Call
Exists indicates an expected call of Exists.
func (*MockSessionStoreMockRecorder) Get ¶
func (mr *MockSessionStoreMockRecorder) Get(key, target any) *gomock.Call
Get indicates an expected call of Get.
func (*MockSessionStoreMockRecorder) GetAndDelete ¶
func (mr *MockSessionStoreMockRecorder) GetAndDelete(key, target any) *gomock.Call
GetAndDelete indicates an expected call of GetAndDelete.
type Mockdatabase ¶
type Mockdatabase struct {
// contains filtered or unexported fields
}
Mockdatabase is a mock of database interface.
func NewMockdatabase ¶
func NewMockdatabase(ctrl *gomock.Controller) *Mockdatabase
NewMockdatabase creates a new mock instance.
func (*Mockdatabase) EXPECT ¶
func (m *Mockdatabase) EXPECT() *MockdatabaseMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockdatabaseMockRecorder ¶
type MockdatabaseMockRecorder struct {
// contains filtered or unexported fields
}
MockdatabaseMockRecorder is the mock recorder for Mockdatabase.
type Provider ¶
type Provider interface {
// GetKVStore returns a key-value store. Stores are identified by a name.
// When identical name is passed the same store is returned.
// Names must be alphanumeric, non-zero strings.
GetKVStore(name string, class Class) (stoabs.KVStore, error)
}
Provider lets callers get access to stores.
type RDSIAMConfig ¶
type RDSIAMConfig struct {
// Enabled determines whether to use AWS IAM authentication for RDS.
Enabled bool `koanf:"enabled"`
// Region is the AWS region where the RDS instance is located.
// If not specified, it will be loaded from the AWS SDK default configuration.
Region string `koanf:"region"`
// DBUser is the database user for IAM authentication.
// If not specified, the user from the connection string will be used.
DBUser string `koanf:"dbuser"`
// TokenRefreshInterval is how often to refresh the IAM token (default: 14 minutes).
// RDS tokens are valid for 15 minutes, so we refresh before expiry.
TokenRefreshInterval time.Duration `koanf:"tokenrefreshinterval"`
}
RDSIAMConfig specifies config for AWS RDS IAM authentication.
type RedisConfig ¶
type RedisConfig struct {
Address string `koanf:"address"`
Username string `koanf:"username"`
Password string `koanf:"password"`
Database string `koanf:"database"`
TLS RedisTLSConfig `koanf:"tls"`
Sentinel RedisSentinelConfig `koanf:"sentinel"`
}
RedisConfig specifies config for Redis databases.
type RedisSentinelConfig ¶
type RedisSentinelConfig struct {
Master string `koanf:"master"`
Nodes []string `koanf:"nodes"`
Username string `koanf:"username"`
Password string `koanf:"password"`
}
RedisSentinelConfig specifies properties for connecting to a Redis Sentinel cluster.
type RedisTLSConfig ¶
type RedisTLSConfig struct {
TrustStoreFile string `koanf:"truststorefile"`
}
RedisTLSConfig specifies properties for connecting to a Redis server over TLS.
type SQLConfig ¶
type SQLConfig struct {
// ConnectionString is the connection string for the SQL database.
// This string may contain secrets (user:password), so should never be logged.
ConnectionString string `koanf:"connection"`
// RDSIAM specifies AWS RDS IAM authentication configuration.
RDSIAM RDSIAMConfig `koanf:"rdsiam"`
}
SQLConfig specifies config for the SQL storage engine.
type SessionConfig ¶
type SessionConfig struct {
// Memcached specifies config for the Memcached session storage engine.
Memcached MemcachedConfig `koanf:"memcached"`
// Redis specifies config for the Redis session storage engine.
Redis RedisConfig `koanf:"redis"`
}
SessionConfig specifies config for the session storage engine.
type SessionDatabase ¶
type SessionDatabase interface {
// GetStore returns a SessionStore with the given keys as key prefixes.
// The keys are used to logically partition the store, eg: tenants and/or flows that are not allowed to overlap like credential issuance and verification.
// The TTL is the time-to-live for the entries in the store.
GetStore(ttl time.Duration, keys ...string) SessionStore
// Close stops any background processes and closes the database.
Close()
// contains filtered or unexported methods
}
SessionDatabase is a non-persistent database that holds session data on a KV basis. Keys could be access tokens, nonce's, authorization codes, etc. All entries are stored with a TTL, so they will be removed automatically.
func NewErrorSessionDatabase ¶
func NewErrorSessionDatabase(err error) SessionDatabase
NewErrorSessionDatabase creates a SessionDatabase that always returns an error.
func NewRedisSessionDatabase ¶
func NewRedisSessionDatabase(client *redis.Client, prefix string) SessionDatabase
type SessionOption ¶
type SessionOption func(target *sessionOptions)
SessionOption is an option that can be given when storing items.
func WithTTL ¶
func WithTTL(ttl time.Duration) SessionOption
WithTTL sets the time-to-live for the stored item.
type SessionStore ¶
type SessionStore interface {
// Delete deletes the entry for the given key.
// It does not return an error if the key does not exist.
Delete(key string) error
// Exists returns true if the key exists.
Exists(key string) bool
// Get returns the value for the given key.
// Returns ErrNotFound if the key does not exist.
Get(key string, target interface{}) error
// Put stores the given value for the given key.
// options can be used to fine-tune the storage of the item.
Put(key string, value interface{}, options ...SessionOption) error
// GetAndDelete combines Get and Delete as a convenience for burning nonce entries.
GetAndDelete(key string, target interface{}) error
}
SessionStore is a key-value store that holds session data. The SessionStore is an abstraction for underlying storage, it automatically adds prefixes for logical partitions.
type SessionStoreImpl ¶
type SessionStoreImpl[T StringOrBytes] struct { // contains filtered or unexported fields }
SessionStoreImpl is an implementation of the SessionStore interface It handles logic for all session store types
func (SessionStoreImpl[T]) Delete ¶
func (s SessionStoreImpl[T]) Delete(key string) error
func (SessionStoreImpl[T]) Exists ¶
func (s SessionStoreImpl[T]) Exists(key string) bool
func (SessionStoreImpl[T]) Get ¶
func (s SessionStoreImpl[T]) Get(key string, target interface{}) error
func (SessionStoreImpl[T]) GetAndDelete ¶
func (s SessionStoreImpl[T]) GetAndDelete(key string, target interface{}) error
func (SessionStoreImpl[T]) Put ¶
func (s SessionStoreImpl[T]) Put(key string, value interface{}, options ...SessionOption) error
type StaticKVStoreProvider ¶
StaticKVStoreProvider contains a single store.
func (*StaticKVStoreProvider) GetKVStore ¶
GetKVStore ignores the inputs and returns the Store, or an error when Store == nil.
type StringOrBytes ¶
StringOrBytes is a type that can be either a string or a byte slice used for generic type constraints
type TransactionKey ¶
type TransactionKey struct{}
TransactionKey is the key used to store the SQL transaction in the context.