state

package
v0.0.0-...-756137a Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	*domain.StateBase
}

State implements persistence for unit state.

func NewState

func NewState(factory database.TxnRunnerFactory) *State

NewState returns a new state reference.

func (*State) EnsureUnitStateRecord

func (st *State) EnsureUnitStateRecord(ctx domain.AtomicContext, uuid string) error

EnsureUnitStateRecord ensures that there is a row in the unit_state table for the input unit UUID. This eliminates the need for upsert statements when updating state for uniter, storage and secrets.

func (*State) GetUnitState

func (st *State) GetUnitState(ctx context.Context, uuid string) (unitstate.RetrievedUnitState, error)

GetUnitState returns the full unit state. The state may be empty. If no unit with the uuid exists, a errors.UnitNotFound error is returned.

func (*State) GetUnitUUIDForName

func (st *State) GetUnitUUIDForName(ctx domain.AtomicContext, name string) (string, error)

GetUnitUUIDForName returns the UUID corresponding to the input unit name. If no unit with the name exists, a errors.UnitNotFound error is returned.

func (*State) SetUnitStateCharm

func (st *State) SetUnitStateCharm(ctx domain.AtomicContext, uuid string, state map[string]string) error

SetUnitStateCharm sets the input key/value pairs as the charm state for the input unit UUID.

func (*State) SetUnitStateRelation

func (st *State) SetUnitStateRelation(ctx domain.AtomicContext, uuid string, state map[int]string) error

SetUnitStateRelation sets the input key/value pairs as the relation state for the input unit UUID.

func (*State) UpdateUnitStateSecret

func (st *State) UpdateUnitStateSecret(ctx domain.AtomicContext, uuid, state string) error

UpdateUnitStateSecret sets the input secret state against the input unit UUID.

func (*State) UpdateUnitStateStorage

func (st *State) UpdateUnitStateStorage(ctx domain.AtomicContext, uuid, state string) error

UpdateUnitStateStorage sets the input storage state against the input unit UUID.

func (*State) UpdateUnitStateUniter

func (st *State) UpdateUnitStateUniter(ctx domain.AtomicContext, uuid, state string) error

UpdateUnitStateUniter sets the input uniter state against the input unit UUID.

Jump to

Keyboard shortcuts

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