state

package
v0.0.0-...-84dfa8d Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Key   string `db:"key"`
	Value string `db:"value"`
}

Annotation represents an annotation in the state layer that we read/write to/from DB.

type State

type State struct {
	*domain.StateBase
}

State represents a type for interacting with the underlying state.

func NewState

func NewState(factory database.TxnRunnerFactory) *State

NewState returns a new State for interacting with the underlying state.

func (*State) GetAnnotations

func (st *State) GetAnnotations(ctx context.Context, id annotations.ID) (map[string]string, error)

GetAnnotations will retrieve all the annotations associated with the given ID from the database. If no annotations are found, an empty map is returned.

func (*State) GetCharmAnnotations

func (st *State) GetCharmAnnotations(ctx context.Context, id annotation.GetCharmArgs) (map[string]string, error)

GetCharmAnnotations will retrieve all the annotations associated with the given ID from the database. If no annotations are found, an empty map is returned.

func (*State) SetAnnotations

func (st *State) SetAnnotations(
	ctx context.Context,
	id annotations.ID,
	values map[string]string,
) error

SetAnnotations associates key/value annotation pairs with a given ID. If an annotation already exists for the given ID, then it will be updated with the given value. First all annotations are deleted, then the given pairs are inserted, so unsetting an annotation is implicit.

func (*State) SetCharmAnnotations

func (st *State) SetCharmAnnotations(
	ctx context.Context,
	id annotation.GetCharmArgs,
	values map[string]string,
) error

SetCharmAnnotations associates key/value annotation pairs with a given ID. If an annotation already exists for the given ID, then it will be updated with the given value. First all annotations are deleted, then the given pairs are inserted, so unsetting an annotation is implicit.

Jump to

Keyboard shortcuts

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