nodeaction

package
v0.0.0-...-0a8b275 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalFirst

func LocalFirst() funcopt.O

LocalFirst makes actions not explicitely Local nor remoted via NodeSelector be treated as local (CRM level).

func WithAsyncFunc

func WithAsyncFunc(f func(context.Context) error) funcopt.O

WithAsyncFunc sets a function to run if the action is async

func WithAsyncTarget

func WithAsyncTarget(s string) funcopt.O

WithAsyncTarget is the node or object state the daemons should orchestrate to reach.

func WithAsyncTime

func WithAsyncTime(d time.Duration) funcopt.O

WithAsyncTime is the maximum duration to wait for an async action It needs WithAsyncWait(true)

func WithAsyncWait

func WithAsyncWait(v bool) funcopt.O

WithAsyncWait runs an event-watcher waiting for target state, global expect reached

func WithAsyncWaitNode

func WithAsyncWaitNode(s string) funcopt.O

func WithAsyncWatch

func WithAsyncWatch(v bool) funcopt.O

WithAsyncWatch runs an event-driven monitor on the selected objects after setting a new target. So the operator can see the orchestration unfolding.

func WithColor

func WithColor(s string) funcopt.O

WithColor activates the colorization of outputs auto => yes if os.Stdout is a tty yes no

func WithFormat

func WithFormat(s string) funcopt.O

WithFormat controls the output data format. <empty> => human readable format json => json machine readable format flat => flattened json (<k>=<v>) machine readable format flat_json => same as flat (backward compat)

func WithLocal

func WithLocal(v bool) funcopt.O

WithLocal routes the action to the CRM instead of remoting it via orchestration or remote execution.

func WithLocalFunc

func WithLocalFunc(f func() (any, error)) funcopt.O

WithLocalFunc sets a function to run if the action is local

func WithRemoteFunc

func WithRemoteFunc(f func(context.Context, string) (any, error)) funcopt.O

WithRemoteFunc sets a function to run if the action is local

func WithRemoteNodes

func WithRemoteNodes(s string) funcopt.O

WithRemoteNodes expands into a selection of nodes to execute the action on.

func WithServer

func WithServer(s string) funcopt.O

WithServer sets the api url.

Types

type Expectation

type Expectation any

type T

type T struct {
	actionrouter.T
	AsyncWaitNode string
	AsyncFunc     func(context.Context) error
	LocalFunc     func() (any, error)
	RemoteFunc    func(context.Context, string) (any, error)
}

T has is an actionrouter.T with a node func

func New

func New(opts ...funcopt.O) *T

func (T) Do

func (t T) Do() error

func (T) DoAsync

func (t T) DoAsync() error

DoAsync uses the agent API to submit a target state to reach via an orchestration.

func (T) DoLocal

func (t T) DoLocal() error

func (T) DoRemote

func (t T) DoRemote() error

DoRemote posts the action to a peer node agent API, for synchronous execution.

func (T) HasLocal

func (t T) HasLocal() bool

func (T) Options

func (t T) Options() actionrouter.T

Options returns the base Action struct

Jump to

Keyboard shortcuts

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