meta

package
v0.0.0-...-dae269f Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMetadatumNotSet = errors.New("metadatum not set")

ErrMetadatumNotSet is returned by various [MetaStorage] functions when a metadatum is not set

Functions

This section is empty.

Types

type Key

type Key string

Key represents a key for metadata.

type Meta

type Meta struct {
	component.Base
	Dependencies struct {
		SQL *sql.SQL
	}
	// contains filtered or unexported fields
}

Component meta is responsible for managing metadata per WissKI Instance

func (*Meta) Provision

func (meta *Meta) Provision(ctx context.Context, instance models.Instance, domain string) error

Provision provisions new meta storage for this instance. NOTE(twiesing): This is a no-op, because we implement Purge.

func (*Meta) Purge

func (meta *Meta) Purge(ctx context.Context, instance models.Instance, domain string) error

Purge purges the storage for the given instance.

func (*Meta) Storage

func (meta *Meta) Storage(slug string) *Storage

Storage returns a Storage for the instance with the given slug. When slug is nil, returns a global storage.

func (*Meta) TableInfo

func (*Meta) TableInfo() component.TableInfo

type Storage

type Storage struct {
	Slug string
	// contains filtered or unexported fields
}

Storage manages metadata for either the entire distillery, or a single slug

func (Storage) Delete

func (s Storage) Delete(ctx context.Context, key Key) error

Delete deletes all metadata with the provided key.

func (Storage) Get

func (s Storage) Get(ctx context.Context, key Key, target any) error

Get retrieves metadata with the provided key and deserializes the first one into target. If no metadatum exists, returns ErrMetadatumNotSet.

func (Storage) GetAll

func (s Storage) GetAll(ctx context.Context, key Key, target func(index, total int) any) error

GetAll receives all metadata with the provided keys. For each received value, the targets function is called with the current index, and total number of results. The function is intended to return a target for deserialization.

When no metadatum exists, targets is not called, and nil error is returned.

func (Storage) Purge

func (s Storage) Purge(ctx context.Context) error

Purge removes all metadata, regardless of key.

func (Storage) Set

func (s Storage) Set(ctx context.Context, key Key, value any) error

Set serializes value and stores it with the provided key. Any other metadata with the same key is deleted.

func (Storage) SetAll

func (s Storage) SetAll(ctx context.Context, key Key, values ...any) error

Set serializes values and stores them with the provided key. Any other metadata with the same key is deleted.

type TypedKey

type TypedKey[Value any] Key

TypedKey represents a convenience wrapper for a given with a given value.

func (TypedKey[Value]) Delete

func (f TypedKey[Value]) Delete(ctx context.Context, m *Storage) error

func (TypedKey[Value]) Get

func (f TypedKey[Value]) Get(ctx context.Context, s *Storage) (value Value, err error)

func (TypedKey[Value]) GetAll

func (f TypedKey[Value]) GetAll(ctx context.Context, m *Storage) (values []Value, err error)

func (TypedKey[Value]) GetOrSet

func (f TypedKey[Value]) GetOrSet(ctx context.Context, s *Storage, dflt Value) (value Value, err error)

func (TypedKey[Value]) Set

func (f TypedKey[Value]) Set(ctx context.Context, m *Storage, value Value) error

func (TypedKey[Value]) SetAll

func (f TypedKey[Value]) SetAll(ctx context.Context, m *Storage, values ...Value) error

Jump to

Keyboard shortcuts

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