Documentation ¶
Index ¶
- Constants
- func ApplyExecOptions(instance *Instance, execOptions *ExecOptions)
- func DefaultConfig() *util.ServiceConfig
- func NewFixedTaskScope(refAttrs map[string]*data.Attribute, task *definition.Task, isInput bool) data.Scope
- func NewWorkingDataScope(parentScope data.Scope, workingData map[string]*data.Attribute) data.Scope
- type ActionCtx
- func (ac *ActionCtx) GetResolver() data.Resolver
- func (ac *ActionCtx) ID() string
- func (ac *ActionCtx) InstanceMetadata() *action.ConfigMetadata
- func (ac *ActionCtx) Ref() string
- func (ac *ActionCtx) Reply(replyData map[string]*data.Attribute, err error)
- func (ac *ActionCtx) Return(returnData map[string]*data.Attribute, err error)
- func (ac *ActionCtx) WorkingData() data.Scope
- type ActivityEvalError
- type AttributeChange
- type ChgType
- type ExecOptions
- type ExecType
- type FixedTaskScope
- type IDGenerator
- type IDResponse
- type Instance
- func (pi *Instance) ActionContext() action.Context
- func (pi *Instance) AddAttr(attrName string, attrType data.Type, value interface{}) *data.Attribute
- func (pi *Instance) DoStep() bool
- func (pi *Instance) FlowDefinition() *definition.Definition
- func (pi *Instance) GetAttr(attrName string) (value *data.Attribute, exists bool)
- func (pi *Instance) GetChanges() *InstanceChangeTracker
- func (pi *Instance) GetReturnData() (map[string]*data.Attribute, error)
- func (pi *Instance) HandleGlobalError()
- func (pi *Instance) ID() string
- func (pi *Instance) InitActionContext(config *action.Config, handler action.ResultHandler)
- func (pi *Instance) MarshalJSON() ([]byte, error)
- func (pi *Instance) Name() string
- func (pi *Instance) ReplyHandler() activity.ReplyHandler
- func (pi *Instance) ResetChanges()
- func (pi *Instance) Restart(id string, provider provider.Provider)
- func (pi *Instance) SetAttrValue(attrName string, value interface{}) error
- func (pi *Instance) SetFlowProvider(provider provider.Provider)
- func (pi *Instance) SetState(state int)
- func (pi *Instance) Start(startAttrs []*data.Attribute) bool
- func (pi *Instance) State() int
- func (pi *Instance) Status() Status
- func (pi *Instance) StepID() int
- func (pi *Instance) UnmarshalJSON(d []byte) error
- func (pi *Instance) UpdateAttrs(attrs []*data.Attribute)
- type InstanceChange
- type InstanceChangeTracker
- func (ict *InstanceChangeTracker) AttrChange(chgType ChgType, attribute *data.Attribute)
- func (ict *InstanceChangeTracker) MarshalJSON() ([]byte, error)
- func (ict *InstanceChangeTracker) ResetChanges()
- func (ict *InstanceChangeTracker) SetState(state int)
- func (ict *InstanceChangeTracker) SetStatus(status Status)
- type LinkData
- type LinkDataChange
- type RecordSnapshotReq
- type RecordStepReq
- type RemoteStateRecorder
- func (sr *RemoteStateRecorder) Enabled() bool
- func (sr *RemoteStateRecorder) Name() string
- func (sr *RemoteStateRecorder) RecordSnapshot(instance *Instance)
- func (sr *RemoteStateRecorder) RecordStep(instance *Instance)
- func (sr *RemoteStateRecorder) Start() error
- func (sr *RemoteStateRecorder) Stop() error
- type RunOptions
- type SimpleReplyHandler
- type StateRecorder
- type Status
- type TaskData
- func (td *TaskData) ActionContext() action.Context
- func (td *TaskData) AddWorkingData(attr *data.Attribute)
- func (td *TaskData) ChildTaskInsts() (taskInsts []model.TaskInst, hasChildTasks bool)
- func (td *TaskData) EnterChildren(taskEntries []*model.TaskEntry)
- func (td *TaskData) EnterLeadingChildren(enterCode int)
- func (td *TaskData) EvalActivity() (done bool, evalErr error)
- func (td *TaskData) EvalLink(link *definition.Link) (result bool, err error)
- func (td *TaskData) Failed(err error)
- func (td *TaskData) FlowDetails() activity.FlowDetails
- func (td *TaskData) FromInstLinks() []model.LinkInst
- func (td *TaskData) GetInput(name string) interface{}
- func (td *TaskData) GetOutput(name string) interface{}
- func (td *TaskData) GetSetting(setting string) (value interface{}, exists bool)
- func (td *TaskData) GetWorkingData(key string) (*data.Attribute, bool)
- func (td *TaskData) HasActivity() bool
- func (td *TaskData) HasAttrs() bool
- func (td *TaskData) HasWorkingData() bool
- func (td *TaskData) InputScope() data.Scope
- func (td *TaskData) MarshalJSON() ([]byte, error)
- func (td *TaskData) OutputScope() data.Scope
- func (td *TaskData) SetOutput(name string, value interface{})
- func (td *TaskData) SetState(state int)
- func (td *TaskData) State() int
- func (td *TaskData) Task() *definition.Task
- func (td *TaskData) TaskName() string
- func (td *TaskData) ToInstLinks() []model.LinkInst
- func (td *TaskData) UnmarshalJSON(d []byte) error
- func (td *TaskData) UpdateWorkingData(key string, value interface{}) error
- type TaskDataChange
- type TaskEnv
- func (te *TaskEnv) FindOrCreateLinkData(link *definition.Link) (linkData *LinkData, created bool)
- func (te *TaskEnv) FindOrCreateTaskData(task *definition.Task) (taskData *TaskData, created bool)
- func (te *TaskEnv) MarshalJSON() ([]byte, error)
- func (te *TaskEnv) NewTaskData(task *definition.Task) *TaskData
- func (te *TaskEnv) UnmarshalJSON(data []byte) error
- type WorkItem
- type WorkItemQueueChange
- type WorkingDataScope
Constants ¶
const ( OpStart = iota // 0 OpResume // 1 OpRestart // 2 )
Variables ¶
This section is empty.
Functions ¶
func ApplyExecOptions ¶
func ApplyExecOptions(instance *Instance, execOptions *ExecOptions)
ApplyExecOptions applies any execution options to the flow instance
func DefaultConfig ¶
func DefaultConfig() *util.ServiceConfig
func NewFixedTaskScope ¶
func NewFixedTaskScope(refAttrs map[string]*data.Attribute, task *definition.Task, isInput bool) data.Scope
NewFixedTaskScope creates a FixedTaskScope
Types ¶
type ActionCtx ¶
type ActionCtx struct {
// contains filtered or unexported fields
}
func (*ActionCtx) GetResolver ¶
func (*ActionCtx) InstanceMetadata ¶
func (ac *ActionCtx) InstanceMetadata() *action.ConfigMetadata
func (*ActionCtx) WorkingData ¶
type ActivityEvalError ¶
type ActivityEvalError struct {
// contains filtered or unexported fields
}
func NewActivityEvalError ¶
func NewActivityEvalError(taskName string, errorType string, errorText string) *ActivityEvalError
func (*ActivityEvalError) Error ¶
func (e *ActivityEvalError) Error() string
func (*ActivityEvalError) TaskName ¶
func (e *ActivityEvalError) TaskName() string
func (*ActivityEvalError) Type ¶
func (e *ActivityEvalError) Type() string
type AttributeChange ¶
AttributeChange represents a change to an Attribute
type ExecOptions ¶
type ExecOptions struct { Patch *support.Patch Interceptor *support.Interceptor }
ExecOptions are optional Patch & Interceptor to be used during instance execution
type FixedTaskScope ¶
type FixedTaskScope struct {
// contains filtered or unexported fields
}
FixedTaskScope is scope restricted by the set of reference attrs and backed by the specified Task
func (*FixedTaskScope) GetAttr ¶
func (s *FixedTaskScope) GetAttr(attrName string) (attr *data.Attribute, exists bool)
GetAttr implements Scope.GetAttr
func (*FixedTaskScope) SetAttrValue ¶
func (s *FixedTaskScope) SetAttrValue(attrName string, value interface{}) error
SetAttrValue implements Scope.SetAttrValue
type IDGenerator ¶
type IDGenerator interface { //NewFlowInstanceID generate a new instance ID NewFlowInstanceID() string }
IDGenerator generates IDs for flow instances
type IDResponse ¶
type IDResponse struct {
ID string `json:"id"`
}
IDResponse is a response object consists of an ID
type Instance ¶
type Instance struct { FlowURI string Flow *definition.Definition RootTaskEnv *TaskEnv EhTaskEnv *TaskEnv FlowModel *model.FlowModel Attrs map[string]*data.Attribute Patch *support.Patch Interceptor *support.Interceptor WorkItemQueue *util.SyncQueue //todo: change to faster non-threadsafe queue ChangeTracker *InstanceChangeTracker `json:"-"` // contains filtered or unexported fields }
Instance is a structure for representing an instance of a Flow
func New ¶
func New(instanceID string, flowURI string, flow *definition.Definition, flowModel *model.FlowModel) *Instance
New creates a new Flow Instance from the specified Flow
func (*Instance) ActionContext ¶
func (*Instance) FlowDefinition ¶
func (pi *Instance) FlowDefinition() *definition.Definition
FlowDefinition returns the Flow that the instance is of
func (*Instance) GetChanges ¶
func (pi *Instance) GetChanges() *InstanceChangeTracker
GetChanges returns the Change Tracker object
func (*Instance) GetReturnData ¶
func (*Instance) HandleGlobalError ¶
func (pi *Instance) HandleGlobalError()
HandleGlobalError handles instance errors
func (*Instance) InitActionContext ¶
func (pi *Instance) InitActionContext(config *action.Config, handler action.ResultHandler)
InitActionContext initialize the action context, should be initialized before execution
func (*Instance) MarshalJSON ¶
MarshalJSON overrides the default MarshalJSON for FlowInstance
func (*Instance) ReplyHandler ¶
func (pi *Instance) ReplyHandler() activity.ReplyHandler
ReplyHandler returns the reply handler for the instance
func (*Instance) ResetChanges ¶
func (pi *Instance) ResetChanges()
ResetChanges resets an changes that were being tracked
func (*Instance) SetAttrValue ¶
SetAttrValue implements api.Scope.SetAttrValue
func (*Instance) SetFlowProvider ¶
SetFlowProvider sets the process.Provider that the instance should use
func (*Instance) Start ¶
Start will start the Flow Instance, returns a boolean indicating if it was able to start
func (*Instance) UnmarshalJSON ¶
UnmarshalJSON overrides the default UnmarshalJSON for FlowInstance
func (*Instance) UpdateAttrs ¶
UpdateAttrs updates the attributes of the Flow Instance
type InstanceChange ¶
type InstanceChange struct { State int Status Status Changes int AttrChanges []*AttributeChange }
InstanceChange represents a change to the instance
type InstanceChangeTracker ¶
type InstanceChangeTracker struct {
// contains filtered or unexported fields
}
InstanceChangeTracker is used to track all changes to an instance
func NewInstanceChangeTracker ¶
func NewInstanceChangeTracker() *InstanceChangeTracker
NewInstanceChangeTracker creates an InstanceChangeTracker
func (*InstanceChangeTracker) AttrChange ¶
func (ict *InstanceChangeTracker) AttrChange(chgType ChgType, attribute *data.Attribute)
AttrChange is called to track a status change of an Attribute
func (*InstanceChangeTracker) MarshalJSON ¶
func (ict *InstanceChangeTracker) MarshalJSON() ([]byte, error)
MarshalJSON overrides the default MarshalJSON for InstanceChangeTracker
func (*InstanceChangeTracker) ResetChanges ¶
func (ict *InstanceChangeTracker) ResetChanges()
ResetChanges is used to reset any tracking data stored on instance objects
func (*InstanceChangeTracker) SetState ¶
func (ict *InstanceChangeTracker) SetState(state int)
SetState is called to track a state change on an instance
func (*InstanceChangeTracker) SetStatus ¶
func (ict *InstanceChangeTracker) SetStatus(status Status)
SetStatus is called to track a status change on an instance
type LinkData ¶
type LinkData struct {
// contains filtered or unexported fields
}
LinkData represents data associated with an instance of a Link
func NewLinkData ¶
func NewLinkData(taskEnv *TaskEnv, link *definition.Link) *LinkData
NewLinkData creates a LinkData for the specified link in the specified task environment
func (*LinkData) Link ¶
func (ld *LinkData) Link() *definition.Link
Link returns the Link associated with ld context
func (*LinkData) MarshalJSON ¶
MarshalJSON overrides the default MarshalJSON for LinkData
func (*LinkData) UnmarshalJSON ¶
UnmarshalJSON overrides the default UnmarshalJSON for LinkData
type LinkDataChange ¶
LinkDataChange represents a change to a LinkData
type RecordSnapshotReq ¶
type RecordSnapshotReq struct { ID int `json:"id"` FlowID string `json:"flowID"` State int `json:"state"` Status int `json:"status"` SnapshotData *Instance `json:"snapshotData"` }
RecordSnapshotReq serializable representation of the RecordSnapshot request
type RecordStepReq ¶
type RecordStepReq struct { ID int `json:"id"` FlowID string `json:"flowID"` State int `json:"state"` Status int `json:"status"` StepData *InstanceChangeTracker `json:"stepData"` }
RecordStepReq serializable representation of the RecordStep request
type RemoteStateRecorder ¶
type RemoteStateRecorder struct {
// contains filtered or unexported fields
}
RemoteStateRecorder is an implementation of StateRecorder service that can access flows via URI
func NewRemoteStateRecorder ¶
func NewRemoteStateRecorder(config *util.ServiceConfig) *RemoteStateRecorder
NewRemoteStateRecorder creates a new RemoteStateRecorder
func (*RemoteStateRecorder) Enabled ¶
func (sr *RemoteStateRecorder) Enabled() bool
func (*RemoteStateRecorder) Name ¶
func (sr *RemoteStateRecorder) Name() string
func (*RemoteStateRecorder) RecordSnapshot ¶
func (sr *RemoteStateRecorder) RecordSnapshot(instance *Instance)
RecordSnapshot implements instance.StateRecorder.RecordSnapshot
func (*RemoteStateRecorder) RecordStep ¶
func (sr *RemoteStateRecorder) RecordStep(instance *Instance)
RecordStep implements instance.StateRecorder.RecordStep
func (*RemoteStateRecorder) Start ¶
func (sr *RemoteStateRecorder) Start() error
Start implements util.Managed.Start()
func (*RemoteStateRecorder) Stop ¶
func (sr *RemoteStateRecorder) Stop() error
Stop implements util.Managed.Stop()
type RunOptions ¶
type RunOptions struct { Op int ReturnID bool FlowURI string InitialState *Instance ExecOptions *ExecOptions }
RunOptions the options when running a FlowAction
type SimpleReplyHandler ¶
type SimpleReplyHandler struct {
// contains filtered or unexported fields
}
SimpleReplyHandler is a simple ReplyHandler that is pass-thru to the action ResultHandler
func (*SimpleReplyHandler) Reply ¶
func (rh *SimpleReplyHandler) Reply(code int, replyData interface{}, err error)
Reply implements ReplyHandler.Reply
type StateRecorder ¶
type StateRecorder interface { // RecordSnapshot records a Snapshot of the FlowInstance RecordSnapshot(instance *Instance) // RecordStep records the changes for the current Step of the Flow Instance RecordStep(instance *Instance) }
StateRecorder is the interface that describes a service that can record snapshots and steps of a Flow Instance
type Status ¶
type Status int
Status is value that indicates the status of a Flow Instance
const ( // StatusNotStarted indicates that the FlowInstance has not started StatusNotStarted Status = 0 // StatusActive indicates that the FlowInstance is active StatusActive Status = 100 // StatusCompleted indicates that the FlowInstance has been completed StatusCompleted Status = 500 // StatusCancelled indicates that the FlowInstance has been cancelled StatusCancelled Status = 600 // StatusFailed indicates that the FlowInstance has failed StatusFailed Status = 700 )
type TaskData ¶
type TaskData struct {
// contains filtered or unexported fields
}
TaskData represents data associated with an instance of a Task
func NewTaskData ¶
func NewTaskData(taskEnv *TaskEnv, task *definition.Task) *TaskData
NewTaskData creates a TaskData for the specified task in the specified task environment
func (*TaskData) ActionContext ¶
FlowDetails implements activity.Context.FlowName method
func (*TaskData) AddWorkingData ¶
func (*TaskData) ChildTaskInsts ¶
ChildTaskInsts implements activity.ActivityContext.ChildTaskInsts method
func (*TaskData) EnterChildren ¶
EnterChildren implements activity.ActivityContext.EnterChildren method
func (*TaskData) EnterLeadingChildren ¶
EnterLeadingChildren implements activity.ActivityContext.EnterLeadingChildren method
func (*TaskData) EvalActivity ¶
EvalActivity implements activity.ActivityContext.EvalActivity method
func (*TaskData) EvalLink ¶
func (td *TaskData) EvalLink(link *definition.Link) (result bool, err error)
EvalLink implements activity.ActivityContext.EvalLink method
func (*TaskData) FlowDetails ¶
func (td *TaskData) FlowDetails() activity.FlowDetails
FlowDetails implements activity.Context.FlowName method
func (*TaskData) FromInstLinks ¶
FromInstLinks implements model.TaskContext.FromInstLinks
func (*TaskData) GetSetting ¶
func (*TaskData) GetWorkingData ¶
func (*TaskData) HasActivity ¶
HasActivity implements activity.ActivityContext.HasActivity method
func (*TaskData) HasWorkingData ¶
func (*TaskData) InputScope ¶
InputScope get the InputScope of the task instance
func (*TaskData) MarshalJSON ¶
MarshalJSON overrides the default MarshalJSON for TaskData
func (*TaskData) OutputScope ¶
OutputScope get the InputScope of the task instance
func (*TaskData) Task ¶
func (td *TaskData) Task() *definition.Task
Task implements model.TaskContext.Task, by returning the Task associated with this TaskData object
func (*TaskData) ToInstLinks ¶
ToInstLinks implements model.TaskContext.ToInstLinks,
func (*TaskData) UnmarshalJSON ¶
UnmarshalJSON overrides the default UnmarshalJSON for TaskData
func (*TaskData) UpdateWorkingData ¶
type TaskDataChange ¶
TaskDataChange represents a change to a TaskData
type TaskEnv ¶
type TaskEnv struct { ID int Task *definition.Task Instance *Instance ParentEnv *TaskEnv TaskDatas map[string]*TaskData LinkDatas map[int]*LinkData // contains filtered or unexported fields }
TaskEnv is a structure that describes the execution environment for a set of tasks
func (*TaskEnv) FindOrCreateLinkData ¶
func (te *TaskEnv) FindOrCreateLinkData(link *definition.Link) (linkData *LinkData, created bool)
FindOrCreateLinkData finds an existing LinkData or creates ones if not found for the specified link the task environment
func (*TaskEnv) FindOrCreateTaskData ¶
func (te *TaskEnv) FindOrCreateTaskData(task *definition.Task) (taskData *TaskData, created bool)
FindOrCreateTaskData finds an existing TaskData or creates ones if not found for the specified task the task environment
func (*TaskEnv) MarshalJSON ¶
MarshalJSON overrides the default MarshalJSON for TaskEnv
func (*TaskEnv) NewTaskData ¶
func (te *TaskEnv) NewTaskData(task *definition.Task) *TaskData
NewTaskData creates a new TaskData object
func (*TaskEnv) UnmarshalJSON ¶
UnmarshalJSON overrides the default UnmarshalJSON for TaskEnv
type WorkItem ¶
type WorkItem struct { ID int `json:"id"` TaskData *TaskData `json:"-"` ExecType ExecType `json:"execType"` EvalCode int `json:"code"` TaskID string `json:"taskID"` //for now need for ser }
WorkItem describes an item of work (event for a Task) that should be executed on Step
type WorkItemQueueChange ¶
WorkItemQueueChange represents a change in the WorkItem Queue
type WorkingDataScope ¶
type WorkingDataScope struct {
// contains filtered or unexported fields
}
WorkingDataScope is scope restricted by the set of reference attrs and backed by the specified Task
func (*WorkingDataScope) GetAttr ¶
func (s *WorkingDataScope) GetAttr(attrName string) (attr *data.Attribute, exists bool)
GetAttr implements Scope.GetAttr
func (*WorkingDataScope) SetAttrValue ¶
func (s *WorkingDataScope) SetAttrValue(attrName string, value interface{}) error
SetAttrValue implements Scope.SetAttrValue