actionstate

package
v0.0.0-...-d3b47b8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID  int64  `db:"id"`
	Tag string `db:"tag"`

	// Receiver is the Name of the Unit or any other ActionReceiver for
	// which this Action is queued.
	Receiver string `db:"receiver"`

	// Name identifies the action that should be run; it should
	// match an action defined by the unit's charm.
	Name string `db:"name"`

	// Parameters holds the action's parameters, if any; it should validate
	// against the schema defined by the named action in the unit's charm.
	Parameters []byte `db:"parameters_json"`

	// Enqueued is the time the action was added.
	Enqueued sql.NullTime `db:"enqueued"`

	// Started reflects the time the action began running.
	Started sql.NullTime `db:"started"`

	// Completed reflects the time that the action was finished.
	Completed sql.NullTime `db:"completed"`

	// Operation is the parent operation of the action.
	Operation string `db:"operation"`

	// Status represents the end state of the Action; ActionFailed for an
	// action that was removed prematurely, or that failed, and
	// ActionCompleted for an action that successfully completed.
	Status sql.NullString `db:"status"`

	// Message captures any error returned by the action.
	Message sql.NullString `db:"message"`
}

func (Action) Fields

func (a Action) Fields(tx *sqlx.Tx) string

Fields returns the list of fields directly from an Action type.

func (Action) ToModel

func (a Action) ToModel() (model.Action, error)

type ActionManager

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

func NewManager

func NewManager(backend Backend) *ActionManager

NewManager creates a new manager from a backend.

func (*ActionManager) ActionByID

func (m *ActionManager) ActionByID(tx *sqlx.Tx, id int64) (model.Action, error)

ActionByID returns one action by id.

func (*ActionManager) ActionByTag

func (m *ActionManager) ActionByTag(tx *sqlx.Tx, tag names.ActionTag) (model.Action, error)

ActionByTag returns one action by tag.

func (*ActionManager) ActionsByName

func (m *ActionManager) ActionsByName(tx *sqlx.Tx, name string) ([]model.Action, error)

ActionsByName returns a slice of actions that have the same name.

func (*ActionManager) AddAction

func (m *ActionManager) AddAction(tx *sqlx.Tx, receiver names.Tag, operationID, actionName string, payload map[string]interface{}) (model.Action, error)

AddAction adds an action, returning the given action.

func (*ActionManager) StartUp

func (m *ActionManager) StartUp(ctx context.Context) error

func (*ActionManager) Stop

func (m *ActionManager) Stop()

type Backend

type Backend interface {
	// Run is a convince function for running one shot transactions, which
	// correctly handles the rollback semantics and retries where available.
	Run(func(context.Context, *sqlx.Tx) error) error
}

Jump to

Keyboard shortcuts

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