store

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFrameNotFound      = errors.New("frame not found")
	ErrFrameAlreadyStored = errors.New("frame already stored")
	ErrFrameInvalid       = errors.New("frame invalid")
)

Functions

func IsValidStoreType

func IsValidStoreType(st Type) bool

Types

type BasicMetrics

type BasicMetrics struct {
	// contains filtered or unexported fields
}

func NewBasicMetrics

func NewBasicMetrics(namespace, storeType string, enabled bool) *BasicMetrics

func (*BasicMetrics) ObserveCacheHit added in v0.0.7

func (m *BasicMetrics) ObserveCacheHit(itemType string)

func (*BasicMetrics) ObserveCacheMiss added in v0.0.7

func (m *BasicMetrics) ObserveCacheMiss(itemType string)

func (*BasicMetrics) ObserveItemAdded

func (m *BasicMetrics) ObserveItemAdded(itemType string)

func (*BasicMetrics) ObserveItemRemoved

func (m *BasicMetrics) ObserveItemRemoved(itemType string)

func (*BasicMetrics) ObserveItemRetreived

func (m *BasicMetrics) ObserveItemRetreived(itemType string)

func (*BasicMetrics) ObserveItemStored

func (m *BasicMetrics) ObserveItemStored(itemType string, count int)

type Config

type Config struct {
	Type   Type            `yaml:"type"`
	Config yaml.RawMessage `yaml:"config"`
}

func (*Config) Validate

func (c *Config) Validate() error

type DataType

type DataType string
const (
	UnknownDataType DataType = "unknown"
	FrameDataType   DataType = "frame"
	BlockDataType   DataType = "block"
)

type FileSystem

type FileSystem struct {
	// contains filtered or unexported fields
}

func NewFileSystem

func NewFileSystem(namespace string, config FileSystemConfig, opts *Options) (*FileSystem, error)

NewFileSystem creates a new FileSystem instance with the specified base directory.

func (*FileSystem) DeleteFrame

func (fs *FileSystem) DeleteFrame(ctx context.Context, id string) error

func (*FileSystem) GetFrame

func (fs *FileSystem) GetFrame(ctx context.Context, id string) (*types.Frame, error)

func (*FileSystem) SaveFrame

func (fs *FileSystem) SaveFrame(ctx context.Context, frame *types.Frame) error

type FileSystemConfig

type FileSystemConfig struct {
	BaseDir string `yaml:"base_dir"`
}

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

func NewMemoryStore

func NewMemoryStore(namespace string, log logrus.FieldLogger, opts *Options) *MemoryStore

func (*MemoryStore) DeleteFrame

func (s *MemoryStore) DeleteFrame(ctx context.Context, id string) error

func (*MemoryStore) GetFrame

func (s *MemoryStore) GetFrame(ctx context.Context, id string) (*types.Frame, error)

func (*MemoryStore) SaveFrame

func (s *MemoryStore) SaveFrame(ctx context.Context, frame *types.Frame) error

type Options

type Options struct {
	MetricsEnabled bool
}

func DefaultOptions

func DefaultOptions() *Options

func (*Options) SetMetricsEnabled

func (o *Options) SetMetricsEnabled(enabled bool) *Options

func (*Options) Validate

func (o *Options) Validate() error

func (*Options) WithMetricsDisabled

func (o *Options) WithMetricsDisabled() *Options

func (*Options) WithMetricsEnabled

func (o *Options) WithMetricsEnabled() *Options

type S3Store

type S3Store struct {
	// contains filtered or unexported fields
}

func NewS3Store

func NewS3Store(namespace string, log logrus.FieldLogger, config *S3StoreConfig, opts *Options) (*S3Store, error)

NewS3Store creates a new S3Store instance with the specified AWS configuration, bucket name, and key prefix.

func (*S3Store) DeleteFrame

func (s *S3Store) DeleteFrame(ctx context.Context, id string) error

func (*S3Store) GetFrame

func (s *S3Store) GetFrame(ctx context.Context, id string) (*types.Frame, error)

func (*S3Store) SaveFrame

func (s *S3Store) SaveFrame(ctx context.Context, frame *types.Frame) error

type S3StoreConfig

type S3StoreConfig struct {
	Endpoint     string `yaml:"endpoint"`
	Region       string `yaml:"region"`
	BucketName   string `yaml:"bucket_name"`
	KeyPrefix    string `yaml:"key_prefix"`
	AccessKey    string `yaml:"access_key"`
	AccessSecret string `yaml:"access_secret"`
	UsePathStyle bool   `yaml:"use_path_style"`
}

type Store

type Store interface {
	// SaveFrame saves a frame to the store
	SaveFrame(ctx context.Context, frame *types.Frame) error
	// GetFrame fetches a frame from the store
	GetFrame(ctx context.Context, id string) (*types.Frame, error)
	// Delete deletes a frame from the store
	DeleteFrame(ctx context.Context, id string) error
}

Store is an interface for different persistence implementations.

func NewStore

func NewStore(namespace string, log logrus.FieldLogger, storeType Type, config yaml.RawMessage, opts *Options) (Store, error)

type Type

type Type string
const (
	UnknownStore        Type = "unknown"
	FileSystemStoreType Type = "fs"
	S3StoreType         Type = "s3"
	MemoryStoreType     Type = "memory"
)

Jump to

Keyboard shortcuts

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