Documentation
¶
Overview ¶
Package process is the public API for execution engine of process. It contains a simple execution framework that can be used to implement a process engine.
Thre are 3 concepts in the package:
* Context: the container of variables and expressions.
* Flow: the process flow definition, mostly the container of nodes.
* State: the state of the process.
The definition of process flow is driven by states while nodes executes to change states and variables.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotRunnable = fmt.Errorf("not runnable") ErrNodeNotFound = fmt.Errorf("node not found") )
predefined errors
Functions ¶
func Run ¶
Run a convenient method to execute the flow instance to a non-runnable state.
Example ¶
package main
type SampleInstance struct {
flow Flow
ctx Context
state State
}
func (i SampleInstance) GetContext() Context {
return i.ctx
}
func (i SampleInstance) GetFlow() Flow {
return i.flow
}
func (i SampleInstance) GetState() State {
return i.state
}
func main() {
var inst SampleInstance
Continue(inst, "start")
if err := Run(inst); err != nil {
panic(err)
}
}
Types ¶
type State ¶
type State interface {
GetCurrentNode() string
Name() StateName
// contains filtered or unexported methods
}
State the state of the process.
type StateName ¶
type StateName interface {
// contains filtered or unexported methods
}
StateName the state name
var ( StateNameRunnable StateName = predefinedStateName("Runnable") StateNameRunning StateName = predefinedStateName("Running") StateNamePending StateName = predefinedStateName("Pending") StateNameCompleted StateName = predefinedStateName("Completed") StateNameTerminated StateName = predefinedStateName("Terminated") StateNameError StateName = predefinedStateName("Error") )
State Names
Click to show internal directories.
Click to hide internal directories.