state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyKey = errors.New("key may not be empty")

Functions

This section is empty.

Types

type Cache

type Cache interface {
	CacheWriter
	StoreReader
}

type CacheWriter

type CacheWriter interface {
	Set(ctx context.Context, key Key, state []byte) error
}

type DB

type DB struct {
	State   Store
	Plugins Plugins
	// contains filtered or unexported fields
}

func NewDB

func NewDB(ctx context.Context, stateFilePath string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

type EntPluginsRepo

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

func NewEntPluginsRepo

func NewEntPluginsRepo(client *ent.Client) *EntPluginsRepo

func (EntPluginsRepo) List

func (e EntPluginsRepo) List(ctx context.Context) ([]Plugin, error)

func (EntPluginsRepo) ModulesForPlugin

func (e EntPluginsRepo) ModulesForPlugin(ctx context.Context, id uuid.UUID) ([]PluginModule, error)

func (EntPluginsRepo) Remove

func (e EntPluginsRepo) Remove(ctx context.Context, id uuid.UUID) error

func (EntPluginsRepo) UpsertModules

func (e EntPluginsRepo) UpsertModules(ctx context.Context, modules []PluginModule) error

func (EntPluginsRepo) UpsertPlugin

func (e EntPluginsRepo) UpsertPlugin(ctx context.Context, p Plugin) (pluginID uuid.UUID, err error)

type EntStateRepository

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

func NewEntStore

func NewEntStore(ctx context.Context, client *ent.Client) (*EntStateRepository, error)

func (*EntStateRepository) Get

func (s *EntStateRepository) Get(ctx context.Context, key Key) (state []byte, meta Metadata, err error)

func (*EntStateRepository) Set

func (s *EntStateRepository) Set(ctx context.Context, key Key, state []byte, opts ...EntryOption) error

type EntryOption

type EntryOption interface {
	// contains filtered or unexported methods
}

func WithTTL

func WithTTL(ttl time.Duration) EntryOption

type EntryOptionFunc

type EntryOptionFunc func(e *ent.KVEntryCreate)

type InMemoryStore

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

func (*InMemoryStore) Get

func (i *InMemoryStore) Get(ctx context.Context, key Key) (state []byte, meta Metadata, err error)

func (*InMemoryStore) Set

func (i *InMemoryStore) Set(_ context.Context, key Key, state []byte, opts ...EntryOption) error

type Key

type Key interface {
	Bytes() []byte
}

type Metadata

type Metadata struct {
	ModifiedAt time.Time
	TTL        *time.Time
}

type PlainKey

type PlainKey []byte

func (PlainKey) Bytes

func (k PlainKey) Bytes() []byte

type Plugin

type Plugin struct {
	ID        *uuid.UUID
	Name      string
	URL       *url.URL
	LocalPath string
	Hash      []byte
}

type PluginModule

type PluginModule struct {
	ID          *uuid.UUID
	Type        string
	DefaultSpec []byte
	Category    commonv1.Category
	PluginID    uuid.UUID
}

type Plugins

type Plugins interface {
	List(ctx context.Context) ([]Plugin, error)
	Remove(ctx context.Context, id uuid.UUID) error
	ModulesForPlugin(ctx context.Context, id uuid.UUID) ([]PluginModule, error)
	UpsertPlugin(ctx context.Context, plugin Plugin) (pluginID uuid.UUID, err error)
	UpsertModules(ctx context.Context, modules []PluginModule) error
}

type StateCache

type StateCache struct {
	Store Store
	TTL   time.Duration
}

func NewStateCache

func NewStateCache(ttl time.Duration, store Store) *StateCache

func (*StateCache) Get

func (s *StateCache) Get(ctx context.Context, key Key) (state []byte, meta Metadata, err error)

func (*StateCache) Set

func (s *StateCache) Set(ctx context.Context, key Key, state []byte) error

type Store

type Store interface {
	StoreWriter
	StoreReader
}

type StoreReader

type StoreReader interface {
	Get(ctx context.Context, key Key) (state []byte, meta Metadata, err error)
}

type StoreWriter

type StoreWriter interface {
	Set(ctx context.Context, key Key, state []byte, opts ...EntryOption) error
}

type StringsKey

type StringsKey []string

func KeyOfStrings

func KeyOfStrings(parts ...any) StringsKey

func (StringsKey) Bytes

func (k StringsKey) Bytes() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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