storage

package
v5.4.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package storage is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var NewDocumentStore newDocumentStoreFunc = func(path string, documentLoader interface{}) (leia.Store, error) {
	return createLeiaStore(path, documentLoader, false)
}

NewDocumentStore is the factory function for creating Leia stores.

Functions

func CreateTestBBoltStore

func CreateTestBBoltStore(tb testing.TB, filePath string) stoabs.KVStore

CreateTestBBoltStore creates an in-memory bbolt store

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 Class

type Class int

Class defines levels of storage reliability.

const (
	// VolatileStorageClass means losing the storage has no/little implications due to data loss (e.g. caches).
	VolatileStorageClass Class = iota
	// PersistentStorageClass means losing the storage should never happen, because it has major implications.
	PersistentStorageClass = iota
)

type Config

type Config struct {
	BBolt BBoltConfig `koanf:"bbolt"`
	Redis RedisConfig `koanf:"redis"`
	// Debug specifies whether to enable debug logging for the storage engine, e.g. performance metrics and query logging.
	Debug bool `koanf:"debug"`
}

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
}

Engine defines the interface for the storage engine.

func New

func New() Engine

New creates a new instance of the storage engine.

func NewTestStorageEngine

func NewTestStorageEngine(testDirectory string) Engine

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

func NewKVBackedLeiaStore(store leia.Store, backup stoabs.KVStore) (KVBackedLeiaStore, error)

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 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) Shutdown

func (m *MockEngine) Shutdown() error

Shutdown mocks base method.

func (*MockEngine) Start

func (m *MockEngine) Start() error

Start 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 interface{}) *gomock.Call

Configure indicates an expected call of Configure.

func (*MockEngineMockRecorder) GetProvider

func (mr *MockEngineMockRecorder) GetProvider(moduleName interface{}) *gomock.Call

GetProvider indicates an expected call of GetProvider.

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

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProvider) GetKVStore

func (m *MockProvider) GetKVStore(name string, class Class) (stoabs.KVStore, error)

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 interface{}) *gomock.Call

GetKVStore indicates an expected call of GetKVStore.

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

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 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 StaticKVStoreProvider

type StaticKVStoreProvider struct {
	Store stoabs.KVStore
}

StaticKVStoreProvider contains a single store.

func (*StaticKVStoreProvider) GetKVStore

func (p *StaticKVStoreProvider) GetKVStore(_ string, _ Class) (stoabs.KVStore, error)

GetKVStore ignores the inputs and returns the Store, or an error when Store == nil.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL