run

package
v0.0.0-...-05fba6c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResultLogEntryFromRequest

func NewResultLogEntryFromRequest(req *BlockExecutionRequest) *log.ResultLogEntry

Types

type BlockCancelRequest

type BlockCancelRequest struct {
	NodeID    string
	RequestID string
}

func NewBlockCancelRequest

func NewBlockCancelRequest(nodeID, requestID string) *BlockCancelRequest

type BlockExecutionRequest

type BlockExecutionRequest struct {
	// CancelFn - can be called by multiple go routines, and is idempotent
	CancelFn    context.CancelFunc
	Ctx         context.Context
	ID          string
	Node        *graph.Node
	Block       *graph.Block
	Stdout      io.Writer
	Stderr      io.Writer
	ExecutionID string
	ExecutedBy  string
}

func NewBlockExecutionRequest

func NewBlockExecutionRequest(n *graph.Node, b *graph.Block, stdout, stderr io.Writer,
	executionID, executedBy string, executionTimeout time.Duration) *BlockExecutionRequest

func (*BlockExecutionRequest) String

func (b *BlockExecutionRequest) String() string

type ExecutionUpdateFn

type ExecutionUpdateFn func(entry *log.ResultLogEntry)

type NodeIndex

type NodeIndex struct {
	sync.Map
}

func NewNodeViewIndex

func NewNodeViewIndex() *NodeIndex

func (*NodeIndex) Add

func (ni *NodeIndex) Add(n *graph.Node) error

func (*NodeIndex) ContainsID

func (ni *NodeIndex) ContainsID(id string) bool

func (*NodeIndex) Get

func (ni *NodeIndex) Get(id string) (*graph.Node, error)

type Run

type Run struct {

	// Unique ID for this execution
	ID string

	// PlaybookID of the playbook snippet to run
	PlaybookID string

	// NodeView of the Root node of execution
	Root *graph.Node

	// NodeViews indexed by NodeID
	ViewIndex *NodeIndex

	// NodeExecutionResult indexed by NodeID
	ExecIndex log.ResultLogIndex

	// Store refers to the graph store
	Store graph.Store

	// Register is the execution library
	Register *executor.Register
	// contains filtered or unexported fields
}

Run encapsulates a playbook's execution

func NewRun

func NewRun(gCtx *snippet.Context, playbookIDOrURL string) (*Run, error)

NewRun constructs a new run for the provided playbook for the

func (*Run) CancelBlock

func (r *Run) CancelBlock(nodeID, requestID string)

func (*Run) EditBlock

func (r *Run) EditBlock(nodeID, blockID string, save bool) (*graph.Node, *graph.Block, error)

func (*Run) EditSnippet

func (r *Run) EditSnippet(nodeID string) (*graph.Node, error)

func (*Run) ExecuteBlock

func (r *Run) ExecuteBlock(n *graph.Node, b *graph.Block, stdout, stderr io.Writer) (string, error)

ExecuteBlock executes the specified block in the context of this node

func (*Run) ExecuteNode

func (r *Run) ExecuteNode(n *graph.Node, stdout, stderr io.Writer) error

ExecuteNode executes all code blocks in the context of this node If any block fails executions, ExecuteNode will return an error and not continue executing

func (*Run) GetBlock

func (r *Run) GetBlock(nodeID, blockID string) (*graph.Block, error)

GetBlock returns the specified block from the local index

func (*Run) GetBlockExecutionResult

func (r *Run) GetBlockExecutionResult(nodeID, logID string) (*log.ResultLogEntry, error)

GetBlockExecutionResult retrieves the execution result for the specified LogID within that node

func (*Run) ReportExecutionInfo

func (r *Run) ReportExecutionInfo(entry *log.ResultLogEntry) error

func (*Run) SetExecutionUpdateFn

func (r *Run) SetExecutionUpdateFn(fn ExecutionUpdateFn)

func (*Run) SetStatusUpdateFn

func (r *Run) SetStatusUpdateFn(fn StatusUpdateFn)

func (*Run) Shutdown

func (r *Run) Shutdown()

Shutdown stops this system. You cannot use Start to start running

func (*Run) Start

func (r *Run) Start()

Start a loop to receive messages

func (Run) String

func (r Run) String() string

type Status

type Status struct {
	Level   StatusLevel
	Message string
}

type StatusLevel

type StatusLevel string
const (
	StatusInfo  StatusLevel = "Info"
	StatusError StatusLevel = "Error"
)

type StatusUpdateFn

type StatusUpdateFn func(*Status)

Jump to

Keyboard shortcuts

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