wf

package
v0.0.0-...-e65cc6c Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Index

Examples

Constants

View Source
const (
	ActionExecutionError     = `WF_ACTION_EXECUTION_ERROR`
	BadParameter             = `WF_BAD_PARAMETER`
	ConditionSyntaxError     = `WF_CONDITION_SYNTAX_ERROR`
	ConditionMissingRp       = `WF_CONDITION_MISSING_RP`
	ConditionInvalidName     = `WF_CONDITION_INVALID_NAME`
	ConditionUnexpectedEnd   = `WF_CONDITION_UNEXPECTED_END`
	ElementNotParameter      = `WF_ELEMENT_NOT_PARAMETER`
	FieldTypeMismatch        = `WF_FIELD_TYPE_MISMATCH`
	IllegalIterationStyle    = `WF_ILLEGAL_ITERATION_STYLE`
	IllegalOperation         = `WF_ILLEGAL_OPERATION`
	InvalidFunction          = `WF_INVALID_FUNCTION`
	InvalidTypeName          = `WF_INVALID_TYPE_NAME`
	IteratorNotOneStep       = `WF_ITERATOR_NOT_ONE_STEP`
	MissingRequiredField     = `WF_MISSING_REQUIRED_FIELD`
	MissingRequiredFunction  = `WF_MISSING_REQUIRED_FUNCTION`
	NoDefinition             = `WF_NO_DEFINITION`
	NoServerBuilderInContext = `WF_NO_SERVER_BUILDER_IN_CONTEXT`
	NotStep                  = `WF_NOT_STEP`
	NotStepDefinition        = `WF_NOT_STEP_DEFINITION`
	StepBuildError           = `WF_STEP_BUILD_ERROR`
	StepNoName               = `WF_STEP_NO_NAME`
	StateCreationError       = `WF_STATE_CREATION_ERROR`
)
View Source
const Always = boolean(true)
View Source
const IterationStyleEach = 1
View Source
const IterationStyleEachPair = 2
View Source
const IterationStyleRange = 3
View Source
const IterationStyleTimes = 4
View Source
const Never = boolean(false)
View Source
const NotFound = ErrorConstant(`not found`)

Error returned by Read, Delete, and Update when the requested state isn't found

Variables

View Source
var CrdType px.Type
View Source
var CrudType px.Type
View Source
var DoType px.Type

Functions

func LeafName

func LeafName(name string) string

func ToError

func ToError(r interface{}) error

Types

type APIBuilder

type APIBuilder interface {
	Builder
	API(interface{})
}

type Action

type Action interface {
	Step

	Function() interface{}
}

func MakeAction

func MakeAction(name string, origin issue.Location, when Condition, parameters, returns []serviceapi.Parameter, function interface{}) Action

func NewAction

func NewAction(ctx px.Context, bf func(ActionBuilder)) Action

type ActionBuilder

type ActionBuilder interface {
	Builder
	Doer(interface{})
}

type Builder

type Builder interface {
	Context() px.Context
	Build() Step
	Name(string)
	When(string)
	Parameters(...serviceapi.Parameter)
	Returns(...serviceapi.Parameter)
	QualifyName(childName string) string
	GetParameters() []serviceapi.Parameter
	GetName() string
	Parameter(name, typeName string) serviceapi.Parameter
}

type CRD

type CRD interface {
	// Create creates the desired state and returns a possibly amended version of that state
	// together with the externalId by which the state can henceforth be identified.
	Create(state px.OrderedMap) (px.OrderedMap, string, error)

	// Read reads and returns the current state identified by the given externalId. The error NotFound
	// is returned when no state can be found.
	Read(externalId string) (px.OrderedMap, error)

	// Delete deletes the state identified by the given externalId. The error NotFound is returned when
	// no state can be found.
	Delete(externalId string) error
}

type CRUD

type CRUD interface {
	CRD

	// Update updates the state identified by the given externalId to a new state and returns a possibly
	// amended version of that state. The error NotFound is returned when no state can be found.
	Update(externalId string, state px.OrderedMap) (px.OrderedMap, error)
}

type Call

type Call interface {
	Step

	// Call is the name of the activity that is called
	Call() string
}

func MakeCall

func MakeCall(name string, origin issue.Location, when Condition, input, output []serviceapi.Parameter, calledStep string) Call

func NewCall

func NewCall(ctx px.Context, bf func(CallBuilder)) Call

type CallBuilder

type CallBuilder interface {
	Builder
	CallTo(string)
}

type ChildBuilder

type ChildBuilder interface {
	Builder
	StateHandler(func(StateHandlerBuilder))
	Resource(func(ResourceBuilder))
	Workflow(func(WorkflowBuilder))
	Action(func(ActionBuilder))
	Call(func(CallBuilder))
	AddChild(Builder)
	Iterator(func(IteratorBuilder))
}

type Condition

type Condition interface {
	fmt.Stringer

	// Precedence returns the operator precedence for this Condition
	Precedence() int

	// IsTrue returns true if the given parameters satisfies the condition, false otherwise
	IsTrue(parameters px.OrderedMap) bool

	// Returns all names in use by this condition and its nested conditions. The returned
	// slice is guaranteed to be unique and sorted alphabetically
	Names() []string
}

A Condition evaluates to true or false depending on its given parameters

func And

func And(conditions []Condition) Condition

And returns a Condition that yields true when all given conditions yield true

func Boolean

func Boolean(v bool) Condition

Boolean returns that Condition that yields the given boolean

func Not

func Not(condition Condition) Condition

Not returns a Condition that yields true when the given condition yields false

func Or

func Or(conditions []Condition) Condition

Or returns a Condition that yields true when at least one of the given conditions yield true

func Parse

func Parse(str string) Condition
Example
pcore.Do(func(px.Context) {
	c := Parse("hello")
	fmt.Println(c)
})
Output:

hello
Example (And)
pcore.Do(func(px.Context) {
	c := Parse("hello and goodbye")
	fmt.Println(c)
})
Output:

hello and goodbye
Example (Not)
pcore.Do(func(px.Context) {
	c := Parse("!(hello and goodbye)")
	fmt.Println(c)
})
Output:

!(hello and goodbye)
Example (Or)
pcore.Do(func(px.Context) {
	c := Parse("greeting and (hello or goodbye)")
	fmt.Println(c)
})
Output:

greeting and (hello or goodbye)

func Truthy

func Truthy(name string) Condition

Truthy returns a Condition that yields true when the variable named by the given name contains a truthy value (i.e. not undef or false)

type ErrorConstant

type ErrorConstant string

func (ErrorConstant) Error

func (e ErrorConstant) Error() string

type IterationStyle

type IterationStyle int

func NewIterationStyle

func NewIterationStyle(style string) IterationStyle

func (IterationStyle) String

func (is IterationStyle) String() string

type Iterator

type Iterator interface {
	Step

	// IterationStyle returns the style of iterator, times, range, each, or eachPair.
	IterationStyle() IterationStyle

	// Producer returns the Step that will be invoked once for each iteration
	Producer() Step

	// Over returns what this iterator will iterate over.
	Over() px.Value

	// Variables returns the variables that this iterator will produce for each iteration. These
	// variables will be removed from the declared parameters set when the final requirements
	// for the step are computed.
	Variables() []serviceapi.Parameter

	// Into names the returns from the iteration
	Into() string
}

func MakeIterator

func MakeIterator(name string, origin issue.Location, when Condition, parameters, returns []serviceapi.Parameter,
	style IterationStyle, producer Step, over px.Value, variables []serviceapi.Parameter, into string) Iterator

func NewIterator

func NewIterator(ctx px.Context, bf func(IteratorBuilder)) Iterator

type IteratorBuilder

type IteratorBuilder interface {
	ChildBuilder
	Style(IterationStyle)
	Over(px.Value)
	Variables(...serviceapi.Parameter)
	Into(into string)
}

type Operation

type Operation int
const Delete Operation = 2
const Read Operation = 1
const Upsert Operation = 3

func NewOperation

func NewOperation(operation string) Operation

func (Operation) String

func (is Operation) String() string

type Resource

type Resource interface {
	Step

	ExternalId() string

	State() State
}

func MakeResource

func MakeResource(name string, origin issue.Location, when Condition, parameters, returns []serviceapi.Parameter, extId string, state State) Resource

func NewResource

func NewResource(ctx px.Context, bf func(ResourceBuilder)) Resource

type ResourceBuilder

type ResourceBuilder interface {
	Builder
	ExternalId(extId string)
	State(state State)
	StateStruct(state interface{})
}

type State

type State interface {
	Type() px.ObjectType
	State() interface{}
}

type StateConverter

type StateConverter func(ctx px.Context, state State, parameters px.OrderedMap) px.PuppetObject

type StateHandler

type StateHandler interface {
	Step

	Interface() interface{}
}

func MakeStateHandler

func MakeStateHandler(name string, origin issue.Location, when Condition, parameters, returns []serviceapi.Parameter, api interface{}) StateHandler

func NewStateHandler

func NewStateHandler(ctx px.Context, bf func(StateHandlerBuilder)) StateHandler

type StateHandlerBuilder

type StateHandlerBuilder interface {
	Builder
	API(interface{})
}

type Step

type Step interface {
	issue.Labeled

	Origin() issue.Location

	// When returns an optional Condition that controls whether or not this step participates
	// in the workflow.
	When() Condition

	// Name returns the fully qualified name of the Step
	Name() string

	// Parameters returns the parameters requirements for the Step
	Parameters() []serviceapi.Parameter

	// Returns returns the definition of that this Step will produce
	Returns() []serviceapi.Parameter
}

An Step of a Workflow. The workflow is an Step in itself and can be used in another Workflow.

type Workflow

type Workflow interface {
	Step

	Steps() []Step
}

func MakeWorkflow

func MakeWorkflow(name string, origin issue.Location, when Condition, parameters, returns []serviceapi.Parameter, steps []Step) Workflow

func NewWorkflow

func NewWorkflow(ctx px.Context, bf func(WorkflowBuilder)) Workflow

type WorkflowBuilder

type WorkflowBuilder interface {
	ChildBuilder
}

Jump to

Keyboard shortcuts

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