service

package
v0.0.0-...-f88c608 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service defines a service for interacting with the underlying state.

func NewService

func NewService(st State) *Service

NewService returns a new Service for interacting with the underlying state.

func (*Service) GetState

func (s *Service) GetState(ctx context.Context, uuid string) (unitstate.RetrievedUnitState, error)

GetState returns the full unit state. The state may be empty.

func (*Service) GetUnitUUIDForName

func (s *Service) GetUnitUUIDForName(ctx context.Context, name string) (string, error)

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

func (*Service) SetState

func (s *Service) SetState(ctx context.Context, as unitstate.UnitState) error

SetState persists the input unit state selectively, based on its populated values.

type State

type State interface {
	domain.AtomicStateBase

	// GetUnitUUIDForName returns the UUID for
	// the unit identified by the input name.
	GetUnitUUIDForName(domain.AtomicContext, string) (string, error)

	// EnsureUnitStateRecord ensures that there is a record
	// for the agent state for the unit with the input UUID.
	EnsureUnitStateRecord(domain.AtomicContext, string) error

	// UpdateUnitStateUniter updates the agent uniter
	// state for the unit with the input UUID.
	UpdateUnitStateUniter(domain.AtomicContext, string, string) error

	// UpdateUnitStateStorage updates the agent storage
	// state for the unit with the input UUID.
	UpdateUnitStateStorage(domain.AtomicContext, string, string) error

	// UpdateUnitStateSecret updates the agent secret
	// state for the unit with the input UUID.
	UpdateUnitStateSecret(domain.AtomicContext, string, string) error

	// SetUnitStateCharm replaces the agent charm
	// state for the unit with the input UUID.
	SetUnitStateCharm(domain.AtomicContext, string, map[string]string) error

	// SetUnitStateRelation replaces the agent relation
	// state for the unit with the input UUID.
	SetUnitStateRelation(domain.AtomicContext, string, map[int]string) error

	// GetUnitState returns the full unit agent state.
	// If no unit with the uuid exists, a [unitstateerrors.UnitNotFound] error
	// is returned.
	// If the units state is empty [unitstateerrors.EmptyUnitState] error is
	// returned.
	GetUnitState(ctx context.Context, uuid string) (unitstate.RetrievedUnitState, error)
}

State defines an interface for interacting with the underlying state.

Jump to

Keyboard shortcuts

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