applicationstore

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentStatusOnline  = types.AgentStatusOnline
	AgentStatusOffline = types.AgentStatusOffline
	AgentStatusError   = types.AgentStatusError
)

Re-export constants

Variables

View Source
var AllStorageTypes = []string{
	sqliteStorageType,
	memoryStorageType,
}

AllStorageTypes defines all available application storage backends

Functions

func IsStorageTypeSupported

func IsStorageTypeSupported(storageType string) bool

IsStorageTypeSupported checks if a storage type is supported

Types

type Agent

type Agent = types.Agent

type AgentStatus

type AgentStatus = types.AgentStatus

type ApplicationStore

type ApplicationStore = types.ApplicationStore

Type aliases for convenience

type ApplicationStoreFactory

type ApplicationStoreFactory interface {
	// CreateApplicationStore creates a types.ApplicationStore
	CreateApplicationStore() (types.ApplicationStore, error)

	// Initialize performs internal initialization of the factory, such as opening connections to the backend store.
	// It is called after all configuration of the factory itself has been done.
	Initialize(logger *zap.Logger) error
}

ApplicationStoreFactory defines an interface for a factory that can create application store implementations.

type Closer

type Closer interface {
	// Close closes the storage and releases resources.
	Close() error
}

Closer defines an interface for closing storage resources.

type Config

type Config = types.Config

type ConfigFilter

type ConfigFilter = types.ConfigFilter

type Factory

type Factory struct {
	Config FactoryConfig
	// contains filtered or unexported fields
}

Factory implements ApplicationStoreFactory interface as a meta-factory for application storage components. It provides a clean abstraction layer over concrete storage implementations, allowing easy switching between different storage backends (SQLite, Memory, PostgreSQL, etc.) without changing the main application code.

func NewFactory

func NewFactory(config FactoryConfig) (*Factory, error)

NewFactory creates the meta-factory. It automatically creates and registers the factory for the configured storage type. Example usage:

config := applicationstore.ConfigFrom(appConfig)
factory, err := applicationstore.NewFactory(config)
if err != nil {
    log.Fatal(err)
}
defer factory.Close()

func NewFactoryFromAppConfig

func NewFactoryFromAppConfig(appConfig *config.Config) (*Factory, error)

NewFactoryFromAppConfig creates a new factory directly from app configuration This is a convenience function that combines ConfigFrom and NewFactory

func (*Factory) Close

func (f *Factory) Close() error

Close closes all underlying factories

func (*Factory) CreateApplicationStore

func (f *Factory) CreateApplicationStore() (types.ApplicationStore, error)

CreateApplicationStore creates an application store using the configured storage type

func (*Factory) GetStorageType

func (f *Factory) GetStorageType() string

GetStorageType returns the configured storage type

func (*Factory) Initialize

func (f *Factory) Initialize(logger *zap.Logger) error

Initialize initializes the meta factory and all underlying factories

type FactoryConfig

type FactoryConfig struct {
	Type string `yaml:"type"`
	Path string `yaml:"path"`
}

FactoryConfig represents the configuration for the application store meta factory

func ConfigFrom

func ConfigFrom(appConfig *config.Config) FactoryConfig

ConfigFrom creates a FactoryConfig from the app storage config

func DefaultConfig

func DefaultConfig() FactoryConfig

DefaultConfig returns a default configuration

type Group

type Group = types.Group

type Purger

type Purger interface {
	// Purge removes all data from the storage.
	Purge(ctx context.Context) error
}

Purger defines an interface that is capable of purging the storage. Only meant to be used from integration tests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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