graph

package
v0.0.0-...-83edfdb Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package graph describes a persistent, reliable completion graph for a process

Index

Constants

View Source
const (
	// StateInitial : The graph has been created but not yet committed, can accept changes
	StateInitial = State("initial")
	// StateCommitted : the graph has been committed and can now terminate and can accept changes
	StateCommitted = State("committed")
	// StateTerminating : No more regular stage executions
	StateTerminating = State("terminating")
	// StateCompleted : No more events/data
	StateCompleted = State("completed")
)
View Source
const MainExecPhase = ExecutionPhase("main")

MainExecPhase indicates the main execution phase of the graph (normal running)

View Source
const TerminationExecPhase = ExecutionPhase("termination")

TerminationExecPhase when termination hooks are running

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletionEventListener

type CompletionEventListener interface {
	//OnExecuteStage indicates that  a stage is due to be executed with the given arguments
	OnExecuteStage(stage *CompletionStage, results []*model.CompletionResult)
	//OnCompleteStage indicates that a stage is finished and its result is available
	OnCompleteStage(stage *CompletionStage, result *model.CompletionResult)
	//OnCompose Stage indicates that another stage should be composed into this one
	OnComposeStage(stage *CompletionStage, composedStage *CompletionStage)
	//OnGraphExecutionFinished indicates that the graph is now finished executing all user stages and cannot be structurally modified
	OnGraphExecutionFinished()
	//OnGraphComplete indicates that the graph has completed processing and can be safely passivated
	OnGraphComplete()
}

CompletionEventListener is a callback interface to receive notifications about stage triggers and graph events

type CompletionGraph

type CompletionGraph struct {
	ID         string
	FunctionID string
	// contains filtered or unexported fields
}

CompletionGraph describes the graph itself

func New

func New(id string, functionID string, listener CompletionEventListener) *CompletionGraph

New Creates a new graph

func (*CompletionGraph) GetStage

func (graph *CompletionGraph) GetStage(stageID string) *CompletionStage

GetStage gets a stage from the graph returns nil if the stage isn't found

func (*CompletionGraph) GetStages

func (graph *CompletionGraph) GetStages() []*CompletionStage

GetStages gets a copy of the list of current stages of the graph - the the stages them selves are the live objects (and may vary after other events are processed)

func (*CompletionGraph) IsCommitted

func (graph *CompletionGraph) IsCommitted() bool

IsCommitted Has the graph been marked as committed by HandleCommitted

func (*CompletionGraph) IsCompleted

func (graph *CompletionGraph) IsCompleted() bool

IsCompleted indicates if the graph is completed

func (*CompletionGraph) NextStageID

func (graph *CompletionGraph) NextStageID() string

NextStageID Returns the next stage ID to use for nodes

func (*CompletionGraph) Recover

func (graph *CompletionGraph) Recover()

Recover Trigger recovers of any pending nodes in the graph any triggered nodes that were pending when the graph is active will be failed with a stage recovery failed error

func (*CompletionGraph) UpdateWithEvent

func (graph *CompletionGraph) UpdateWithEvent(event model.Event, mayTrigger bool)

UpdateWithEvent updates this graph's state acGetGraphStateRequestcording to the received event

func (*CompletionGraph) ValidateCommand

func (graph *CompletionGraph) ValidateCommand(cmd model.Command) error

ValidateCommand validates whether the given command can be correctly applied to the current graph's state

type CompletionStage

type CompletionStage struct {
	ID string
	// contains filtered or unexported fields
}

CompletionStage is a node in Graph, this implements StageDependency

func (*CompletionStage) GetClosure

func (stage *CompletionStage) GetClosure() *model.BlobDatum

GetClosure returns the closure for this stage

func (*CompletionStage) GetDeps

func (stage *CompletionStage) GetDeps() []StageDependency

GetDeps gets the dependencies of a stage (this is mutable)

func (*CompletionStage) GetID

func (stage *CompletionStage) GetID() string

GetID gets the ID of a raw dependency

func (*CompletionStage) GetOperation

func (stage *CompletionStage) GetOperation() model.CompletionOperation

GetOperation returns the operation for this stage

func (*CompletionStage) GetResult

func (stage *CompletionStage) GetResult() *model.CompletionResult

GetResult gets the result (or nil if no result) of teh graph

func (*CompletionStage) IsFailed

func (stage *CompletionStage) IsFailed() bool

IsFailed indicates if the stage has completed with a failure

func (*CompletionStage) IsResolved

func (stage *CompletionStage) IsResolved() bool

IsResolved indicates if the stage is resolved

func (*CompletionStage) IsSuccessful

func (stage *CompletionStage) IsSuccessful() bool

IsSuccessful indicates if the stage has completed successful

func (*CompletionStage) IsTriggered

func (stage *CompletionStage) IsTriggered() bool

IsTriggered indicates if this node has been triggered - nodes may only be triggered once

func (*CompletionStage) WhenComplete

func (stage *CompletionStage) WhenComplete() *actor.Future

WhenComplete returns a Future returning a *model.CompletionResult

type ExecutionPhase

type ExecutionPhase string

ExecutionPhase tags stages into when in the graph they occur - stages may depend on other stages within a phase but not across two phases.

type ExecutionStrategy

type ExecutionStrategy func(stage *CompletionStage, listener CompletionEventListener, results []*model.CompletionResult)

ExecutionStrategy defines how the node should behave when it is triggered (optionally calling the attached node closure and how the arguments to the closure are defined) different strategies can be applied when the stage completes successfully or exceptionally

type RawDependency

type RawDependency struct {
	ID string
	// contains filtered or unexported fields
}

RawDependency - is a trivial StageDependency that implements a StageDependency from a completion result

func (*RawDependency) GetID

func (r *RawDependency) GetID() string

GetID gets the ID of a raw dependency

func (*RawDependency) GetResult

func (r *RawDependency) GetResult() *model.CompletionResult

GetResult gets the result (or nil if no result) of teh graph

func (*RawDependency) IsFailed

func (r *RawDependency) IsFailed() bool

IsFailed indicates if the stage has completed with a failure

func (*RawDependency) IsResolved

func (r *RawDependency) IsResolved() bool

IsResolved indicates if the stage is resolved

func (*RawDependency) IsSuccessful

func (r *RawDependency) IsSuccessful() bool

IsSuccessful indicates if the stage has completed successful

func (*RawDependency) SetResult

func (r *RawDependency) SetResult(result *model.CompletionResult)

SetResult sets the result of a Raw Result

type ResultHandlingStrategy

type ResultHandlingStrategy func(stage *CompletionStage, graph *CompletionGraph, stageInvokeResult *model.CompletionResult)

ResultHandlingStrategy defines how the result value of the stage is derived following execution of the stage if the result completes the node then implementations should signal to the graph that the node is complete (via graph.listener) this operation may moodify the graph (e.g. in a compose)

type StageDependency

type StageDependency interface {
	GetID() string
	IsResolved() bool
	IsFailed() bool
	IsSuccessful() bool
	GetResult() *model.CompletionResult
}

StageDependency is an abstract dependency of another stage - this may either be another stage (see CompletionStage) or a raw dependency (RawDependency)

type State

type State string

State describes the lifecycle state of graph

type TriggerStrategy

type TriggerStrategy func(deps []StageDependency) (shouldTrigger bool, successfulTrigger bool, inputs []*model.CompletionResult)

TriggerStrategy defines when a stage becomes active , and what the incoming status of the trigger is (success or fail) each type may or may not depend on the incoming dependencies of the node

Jump to

Keyboard shortcuts

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