action

package
v0.0.0-...-cb4a510 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 9 Imported by: 0

Documentation

Overview

The 'action' package contains all the built-in functions and effects wfx supports and makes available to users.

One might say that a "target" is composed of calls to "actions". And, optionally, other starlark functions of the user's defining (but those in turn surely lead to some actions being called eventually, or they won't have much effect!).

The most common action is probably "cmd" (which hands off work to a shell invocation), but there are many others.

Actions take the form of a `starlark.Callable`, because that's what they need to be in order to be usable from starlark code, which is what the users write.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionPlan

type ActionPlan struct {
	Name_     string      // what this action considers itself named.
	Label     string      // user defined label, which may appear in output log decorations.
	Details   interface{} // used in String() if provided
	Stdin     io.ReadCloser
	Stdout    io.WriteCloser
	Stderr    io.WriteCloser
	IsExec    bool             // if two siblings in a pipe are both true for this, use MkPipe to wire them together instead of application level buffer bouncing.
	Run       func() error     // note: do be prepared for this to be run in a goroutine; it very well might be (e.g. pipe will tend to do this); or, it might not.
	Ignorable func(error) bool // NYI.  we'll see if this is a plausible idea or not.
}

ActionPlan is something that a wfx script is ready to "do". The action described by the ActionPlan can have side effects. Several essential action plan constructors are exported to wfx scripts by default, and form the basis for most, if not all, effects.

ActionPlan are produced by various constructor functions. They can be forced to execute manually by giving them to `do()`; otherwise, simply letting them fall to the ground as the unused result of a starlark statement will cause them to be executed(!). (Any use of the value -- either handing it to other functions, or simply assigning it to a variable -- prevents execution.)

When executed, action will resolve to produce success or an error code; while in motion, the action can consume a stdin stream, and produce stdout and stderr streams. This sounds a lot like a posix process -- and indeed, it's modeled on it! -- and often even backed by a posix process! But can also be implemented without full subprocess execution.

In starlark, execution of the action doesn't return anything. It only succeeds or fails. If it fails, the program as a whole will halt. Other "controller" actions can wrap an action plan and modify it in order configure behaviors other than halt-on-error. The "pipe", "gather", "test", and "ignorantly" controller actions are all examples of things that can tweak the halt conditions in various ways. ("test" is an especially interesting one, in that it actually _does_ return a result -- a boolean.)

Stdout (unless rewired by a piping) goes to dev null, unless verbose mode is on; then, it's decorated and emitted to the user. Stderr goes to dev null, unless the action fails; then it's likely to get included in the error message.

Most ActionPlan are produced by builtin constructors, but they can be defined in Starlark code too. The main reason to consider doing so is to take advantage of the IO streaming conventions, so that the Starlark code can be composed with "pipe" and other action controllers. (Not yet implemented!)

func (*ActionPlan) Freeze

func (a *ActionPlan) Freeze()

func (*ActionPlan) Hash

func (a *ActionPlan) Hash() (uint32, error)

func (*ActionPlan) Name

func (a *ActionPlan) Name() string

func (*ActionPlan) String

func (a *ActionPlan) String() string

func (*ActionPlan) Truth

func (a *ActionPlan) Truth() starlark.Bool

func (*ActionPlan) Type

func (a *ActionPlan) Type() string

type CmdPlanConstructor

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

func (*CmdPlanConstructor) CallInternal

func (a *CmdPlanConstructor) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

func (*CmdPlanConstructor) Freeze

func (a *CmdPlanConstructor) Freeze()

func (*CmdPlanConstructor) Hash

func (a *CmdPlanConstructor) Hash() (uint32, error)

func (*CmdPlanConstructor) Name

func (a *CmdPlanConstructor) Name() string

func (*CmdPlanConstructor) String

func (a *CmdPlanConstructor) String() string

func (*CmdPlanConstructor) Truth

func (a *CmdPlanConstructor) Truth() starlark.Bool

func (*CmdPlanConstructor) Type

func (a *CmdPlanConstructor) Type() string

type Do

type Do struct{}

func (*Do) CallInternal

func (a *Do) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

func (*Do) Freeze

func (a *Do) Freeze()

func (*Do) Hash

func (a *Do) Hash() (uint32, error)

func (*Do) Name

func (a *Do) Name() string

func (*Do) String

func (a *Do) String() string

func (*Do) Truth

func (a *Do) Truth() starlark.Bool

func (*Do) Type

func (a *Do) Type() string

type PanicAction

type PanicAction struct {
}

func (*PanicAction) CallInternal

func (a *PanicAction) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

func (*PanicAction) Freeze

func (a *PanicAction) Freeze()

func (*PanicAction) Hash

func (a *PanicAction) Hash() (uint32, error)

func (*PanicAction) Name

func (a *PanicAction) Name() string

func (*PanicAction) String

func (a *PanicAction) String() string

func (*PanicAction) Truth

func (a *PanicAction) Truth() starlark.Bool

func (*PanicAction) Type

func (a *PanicAction) Type() string

type PipeControllerConstructor

type PipeControllerConstructor struct{}

func (*PipeControllerConstructor) CallInternal

func (a *PipeControllerConstructor) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

func (*PipeControllerConstructor) Freeze

func (a *PipeControllerConstructor) Freeze()

func (*PipeControllerConstructor) Hash

func (a *PipeControllerConstructor) Hash() (uint32, error)

func (*PipeControllerConstructor) Name

func (*PipeControllerConstructor) String

func (a *PipeControllerConstructor) String() string

func (*PipeControllerConstructor) Truth

func (*PipeControllerConstructor) Type

Jump to

Keyboard shortcuts

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