Documentation ¶
Overview ¶
Package workflow provides a workflow plan that can be executed.
Index ¶
- func Secure(v *Plan)
- func Validate(p *Plan) error
- type Action
- func (a *Action) Clone() *Action
- func (a *Action) Defaults()
- func (a *Action) GetID() uuid.UUID
- func (a *Action) GetState() *State
- func (a *Action) HasRegister() bool
- func (a *Action) SetID(id uuid.UUID)
- func (a *Action) SetRegister(r *registry.Register)
- func (a *Action) SetState(state *State)
- func (a *Action) Type() ObjectType
- type Attempt
- type Block
- type Checks
- type FailureReason
- type Object
- type ObjectType
- type Plan
- type Sequence
- type State
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct { // ID is a unique identifier for the object. Should not be set by the user. ID uuid.UUID // Name is the name of the Action. Required. Name string // Descr is a description of the Action. Required. Descr string // Plugin is the name of the plugin that is executed. Required. Plugin string // Timeout is the amount of time to wait for the Action to complete. This defaults to 30 seconds and // must be at least 5 seconds. Timeout time.Duration // Retries is the number of times to retry the Action if it fails. This defaults to 0. Retries int // Req is the request object that is passed to the plugin. Req any // Attempts is the attempts of the action. This should not be set by the user. Attempts []*Attempt // State represents settings that should not be set by the user, but users can query. State *State // contains filtered or unexported fields }
Action represents a single action that is executed by a plugin.
func (*Action) Defaults ¶
func (a *Action) Defaults()
Defaults sets the default values for the object. For use internally.
func (*Action) HasRegister ¶
func (*Action) SetRegister ¶
SetRegister sets the register for the Action. This should not be used by the user.
type Attempt ¶
type Attempt struct { // Resp is the response object that is returned by the plugin. Resp any // Err is the plugin error that is returned by the plugin. If this is not nil, the attempt failed. Err *plugins.Error // Start is the time the attempt started. Start time.Time // End is the time the attempt ended. End time.Time }
Attempt is the result of an action that is executed by a plugin. Nothing in Attempt should be set by the user.
type Block ¶
type Block struct { // ID is a unique identifier for the object. Should not be set by the user. ID uuid.UUID // Name is the name of the block. Required. Name string // Descr is a description of the block. Required. Descr string // EntranceDelay is the amount of time to wait before the block starts. This defaults to 0. EntranceDelay time.Duration // ExitDelay is the amount of time to wait after the block has completed. This defaults to 0. ExitDelay time.Duration // PreChecks are actions that are executed before the block starts. // Any error will cause the block to fail. Optional. PreChecks *Checks // Checks are actions that are executed while the block is running. Optional. ContChecks *Checks // PostChecks are actions that are executed after the block has completed. // Any error will cause the block to fail. Optional. PostChecks *Checks // Sequences is a list of sequences that are executed. Required.. Sequences []*Sequence // Concurrency is the number of sequences that are executed in parallel. This defaults to 1. Concurrency int // ToleratedFailures is the number of sequences that are allowed to fail before the block fails. This defaults to 0. // If set to -1, all sequences are allowed to fail. ToleratedFailures int // State represents settings that should not be set by the user, but users can query. State *State }
Block represents a set of replated work. It contains a list of sequences that are executed with a configurable amount of concurrency. If a block fails, the workflow will fail. Only one block can be executed at a time.
func (*Block) Clone ¶
Clone makes a copy of the block, but without an ID or State. All checks and sequences are cloned acccording to their Clone() method.
func (*Block) Defaults ¶
func (b *Block) Defaults()
Defaults sets the default values for the object. For use internally.
type Checks ¶
type Checks struct { // ID is a unique identifier for the object. Should not be set by the user. ID uuid.UUID // Delay is the amount of time to wait before executing the checks. This // is only used by continuous checks. Optional. Defaults to 30 seconds. Delay time.Duration // Actions is a list of actions that are executed in parallel. Any error will // cause the workflow to fail. Required. Actions []*Action // State represents the internal state of the object. Should not be set by the user. State *State }
Checks represents a set of actions that are executed before the workflow starts.
func (*Checks) Clone ¶
Clone clones the Checks object. This does not copy the ID or the State object. All actions are cloned according to their Clone() method.
func (*Checks) Defaults ¶
func (c *Checks) Defaults()
Defaults sets the default values for the object. For use internally.
type FailureReason ¶
type FailureReason int
FailureReason represents the reason that a workflow failed.
const ( // FRUnknown represents a failure reason that is unknown. // This is the case when a workflow is not in a completed state (a state above 500) // or the state is WFCompleted. FRUnknown FailureReason = 0 // Unknown // FRPreCheck represents a failure reason that occurred during pre-checks. FRPreCheck FailureReason = 100 // PreCheck // FRBlock represents a failure reason that occurred during a block. FRBlock FailureReason = 200 // Block // FRPostCheck represents a failure reason that occurred during post-checks. FRPostCheck FailureReason = 300 // PostCheck // FRContCheck represents a failure reason that occurred during a continuous check. FRContCheck FailureReason = 400 // ContCheck // FRStopped represents a failure reason that occurred because the workflow was stopped. FRStopped FailureReason = 500 // Stopped )
func (FailureReason) String ¶
func (i FailureReason) String() string
type Object ¶
type Object interface { // Type returns the type of the object. Type() ObjectType // contains filtered or unexported methods }
Object is an interface that all workflow objects must implement.
type ObjectType ¶
type ObjectType int
ObjectType is the type of object.
const ( // OTUnknown represents an unknown object type. This is // an indication of a bug. OTUnknown ObjectType = 0 // OTPlan represents a workflow plan. OTPlan ObjectType = 1 // OTCheck represents a check object. OTCheck ObjectType = 2 // OTBlock represents a Block. OTBlock ObjectType = 5 // OTSequence represents a Sequence. OTSequence ObjectType = 6 // OTAction represents an Action. OTAction ObjectType = 7 )
func (ObjectType) String ¶
func (i ObjectType) String() string
type Plan ¶
type Plan struct { // ID is a unique identifier for the object. Should not be set by the user. ID uuid.UUID // Name is the name of the workflow. Required. Name string // Descr is a human-readable description of the workflow. Required. Descr string // A GroupID is a unique identifier for a group of workflows. This is used to group // workflows together for informational purposes. This is not required. GroupID uuid.UUID // Meta is any type of metadata that the user wants to store with the workflow. // This is not used by the workflow engine. Optional. Meta []byte // PreChecks are actions that are executed before the workflow starts. // Any error will cause the workflow to fail. Optional. PreChecks *Checks // ContChecks are actions that are executed while the workflow is running. // Any error will cause the workflow to fail. Optional. ContChecks *Checks // Checks are actions that are executed after the workflow has completed. // Any error will cause the workflow to fail. Optional. PostChecks *Checks // Blocks is a list of blocks that are executed in sequence. // If a block fails, the workflow will fail. // Only one block can be executed at a time. Required. Blocks []*Block // State is the internal state of the object. Should not be set by the user. State *State // SubmitTime is the time that the object was submitted. This is only // set for the Plan object SubmitTime time.Time // Reason is the reason that the object failed. // This will be set to FRUnknown if not in a failed state. Reason FailureReason }
Plan represents a workflow plan that can be executed. This is the main struct that is used to define the workflow.
func (*Plan) Clone ¶
Clone clones a plan with no ID, State, SubmitTime or Reason. It also clones all of the sub-objects according to their Clone() method.
func (*Plan) Defaults ¶
func (p *Plan) Defaults()
Defaults sets the default values for the object. For use internally.
func (*Plan) GetState ¶
GetStates is a getter for the State settings. This violates Go naming for getters, but this is because we expose State on most objects by the State name (unlike most getter/setters). This is here to enable an interface for getting State on all objects.
type Sequence ¶
type Sequence struct { // ID is a unique identifier for the object. Should not be set by the user. ID uuid.UUID // Name is the name of the sequence. Required. Name string // Descr is a description of the sequence. Required. Descr string // Actions is a list of actions that are executed in sequence. Any error will cause the workflow to fail. Required. Actions []*Action // State represents settings that should not be set by the user, but users can query. State *State }
Sequence represents a set of Actions that are executed in sequence. Any error will cause the workflow to fail.
func (*Sequence) Clone ¶
Clone clones an Sequence with no ID and no State. Also clones all the Actions following the cloning rules of the Action.Clone() method.
func (*Sequence) Defaults ¶
func (s *Sequence) Defaults()
Defaults sets the default values for the object. For use internally.
type State ¶
type State struct { // Status is the status of the object. Status Status // Start is the time that the object was started. Start time.Time // End is the time that the object was completed. End time.Time }
State represents the internal state of a workflow object.
type Status ¶
type Status int
Status represents the status of a various workflow objects. Not all objects will have all statuses.
const ( // NotStarted represents an object that has not started execution. NotStarted Status = 0 // NotStarted // Running represents an object that is currently running. Running Status = 100 // Running // Completed represents an object that has completed successfully. For a Plan, // this indicates a successful execution, but does not mean that the workflow did not have errors. Completed Status = 200 // Completed // Failed represents an object that has failed. Failed Status = 300 // Failed // Stopped represents an object that has been stopped by a user action. Stopped Status = 400 // Stopped )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package builder allows building a workflow Plan sequentially instead of constructing a Plan object manually.
|
Package builder allows building a workflow Plan sequentially instead of constructing a Plan object manually. |
Package storage provides the storage interfaces for reading and writing workflow.Plan data.
|
Package storage provides the storage interfaces for reading and writing workflow.Plan data. |
sqlite
Package sqlite provides a sqlite-based storage implementation for workflow.Plan data.
|
Package sqlite provides a sqlite-based storage implementation for workflow.Plan data. |
utils
|
|
html/internal/embeded
Package embeded provides embeded files for multiple packages.
|
Package embeded provides embeded files for multiple packages. |
html/internal/embeded/reporter
Reporter pvovides a binary file that will read the reports from a sub-directory called "report" and serve them on a web server.
|
Reporter pvovides a binary file that will read the reports from a sub-directory called "report" and serve them on a web server. |
html/reports
Package reports provides a way to render a workflow.Plan to an HTML document with a program that will let you read it.
|
Package reports provides a way to render a workflow.Plan to an HTML document with a program that will let you read it. |
walk
Package walk provides a way to walk a workflow.Plan for all objects under it.
|
Package walk provides a way to walk a workflow.Plan for all objects under it. |