Help us shape the future of Go! Take the 2026 Go Developer Survey

instance

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpStart   = iota // 0
	OpResume         // 1
	OpRestart        // 2
)

Variables

This section is empty.

Functions

func ApplyExecOptions

func ApplyExecOptions(instance *IndependentInstance, execOptions *ExecOptions)

ApplyExecOptions applies any execution options to the flow instance

func EnableChangeTracking

func EnableChangeTracking(enable bool, mode state.RecordingMode)

func GetFlowIOMetadata

func GetFlowIOMetadata(flowURI string) (*metadata.IOMetadata, error)

func NewErrorObj

func NewErrorObj(taskId string, msg string) map[string]interface{}

func NewStateInstanceRecorder

func NewStateInstanceRecorder(recorder state.Recorder, mod state.RecordingMode, rerunstate bool) *stateInstanceRecorder

func StartSubFlow

func StartSubFlow(ctx activity.Context, flowURI string, inputs map[string]interface{}) error

Types

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 ChangeTracker

type ChangeTracker interface {
	// FlowCreated is called to track a when a flow is created
	FlowCreated(flow *IndependentInstance)
	// FlowDone is called to track a when a flow complete
	FlowDone(flow *IndependentInstance)
	// SetStatus is called to track a status change on an instance
	SetStatus(subflowId int, status model.FlowStatus)
	// AttrChange is called to track when Attribute changes
	AttrChange(subflowId int, name string, value interface{})
	// SubflowCreated is called to track a when a subflow is created
	SubflowCreated(subflow *Instance)
	// SubflowDone is called to track a when a subflow complete
	SubflowDone(subflow *Instance)
	// WorkItemAdded records when an item is added to the WorkQueue
	WorkItemAdded(wi *WorkItem)
	// WorkItemRemoved records when an item is removed from the WorkQueue
	WorkItemRemoved(wi *WorkItem)
	// TaskAdded records when a Task is added
	TaskAdded(taskInst *TaskInst)
	// TaskUpdated records when a Task is updated
	TaskUpdated(taskInst *TaskInst)
	// TaskRemoved records when a Task is removed
	TaskRemoved(subflowId int, taskId string)
	// LinkAdded records a Link is added
	LinkAdded(linkInst *LinkInst)
	// LinkUpdated records a Link is updated
	LinkUpdated(linkInst *LinkInst)
	// LinkRemoved records when a Link is removed
	LinkRemoved(subflowId int, linkId int)
	// ExtractStep extracts the step object and resets the tracker
	ExtractStep(reset bool) *state.Step
}

func NewInstanceChangeTracker

func NewInstanceChangeTracker(flowId string, startStepId int) ChangeTracker

type ExecOptions

type ExecOptions struct {
	Patch       *support.Patch
	Interceptor *support.Interceptor
}

ExecOptions are optional Patch & Interceptor to be used during instance execution

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 IndependentInstance

type IndependentInstance struct {
	*Instance
	// contains filtered or unexported fields
}

func NewIndependentInstance

func NewIndependentInstance(instanceID string, flowURI string, flow *definition.Definition, instRecorder *stateInstanceRecorder, logger log.Logger) (*IndependentInstance, error)

New creates a new Flow Instance from the specified Flow

func (*IndependentInstance) ApplyInterceptor

func (inst *IndependentInstance) ApplyInterceptor(interceptor *flowsupport.Interceptor)

func (*IndependentInstance) ApplyPatch

func (inst *IndependentInstance) ApplyPatch(patch *flowsupport.Patch)

func (*IndependentInstance) CurrentStep

func (inst *IndependentInstance) CurrentStep(reset bool) *state.Step

func (*IndependentInstance) DoStep

func (inst *IndependentInstance) DoStep() bool

func (*IndependentInstance) ExecutionTime

func (inst *IndependentInstance) ExecutionTime() time.Duration

func (*IndependentInstance) GetChanges

func (inst *IndependentInstance) GetChanges() ChangeTracker

GetChanges returns the Change Tracker object

func (*IndependentInstance) GetFlowState

func (inst *IndependentInstance) GetFlowState(inputs map[string]interface{}) *state.FlowState

func (*IndependentInstance) GetInterceptor

func (inst *IndependentInstance) GetInterceptor() *flowsupport.Interceptor

func (*IndependentInstance) HandleGlobalError

func (inst *IndependentInstance) HandleGlobalError(containerInst *Instance, err error)

HandleGlobalError handles instance errors

func (*IndependentInstance) MarshalJSON

func (inst *IndependentInstance) MarshalJSON() ([]byte, error)

MarshalJSON overrides the default MarshalJSON for FlowInstance

func (*IndependentInstance) RecordState

func (inst *IndependentInstance) RecordState(strtTime time.Time) error

func (*IndependentInstance) ResetChanges

func (inst *IndependentInstance) ResetChanges()

ResetChanges resets an changes that were being tracked

func (*IndependentInstance) Restart

func (inst *IndependentInstance) Restart(logger log.Logger, id string, initStepId int) error

// Restart indicates that this FlowInstance was restarted

func (*IndependentInstance) SetInstanceRecorder

func (inst *IndependentInstance) SetInstanceRecorder(stateRecorder *stateInstanceRecorder)

func (*IndependentInstance) SetTracingContext

func (inst *IndependentInstance) SetTracingContext(tracingCtx trace.TracingContext)

func (*IndependentInstance) Snapshot

func (inst *IndependentInstance) Snapshot() *state.Snapshot

func (*IndependentInstance) Start

func (inst *IndependentInstance) Start(startAttrs map[string]interface{}) bool

func (*IndependentInstance) StepID

func (inst *IndependentInstance) StepID() int

StepID returns the current step ID of the Flow Instance

func (*IndependentInstance) UnmarshalJSON

func (inst *IndependentInstance) UnmarshalJSON(d []byte) error

UnmarshalJSON overrides the default UnmarshalJSON for FlowInstance

func (*IndependentInstance) UpdateStartTime

func (inst *IndependentInstance) UpdateStartTime()

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

func (*Instance) FindOrCreateLinkData

func (inst *Instance) FindOrCreateLinkData(link *definition.Link) (linkInst *LinkInst, created bool)

FindOrCreateLinkData finds an existing LinkInst or creates ones if not found for the specified link the task environment

func (*Instance) FindOrCreateTaskInst

func (inst *Instance) FindOrCreateTaskInst(task *definition.Task) (taskInst *TaskInst, created bool)

FindOrCreateTaskInst finds an existing TaskInst or creates ones if not found for the specified task the task environment

func (*Instance) FlowDefinition

func (inst *Instance) FlowDefinition() *definition.Definition

FlowDefinition returns the Flow definition associated with this context

func (*Instance) FlowURI

func (inst *Instance) FlowURI() string

func (*Instance) GetError

func (inst *Instance) GetError() error

func (*Instance) GetMasterScope

func (inst *Instance) GetMasterScope() data.Scope

func (*Instance) GetReturnData

func (inst *Instance) GetReturnData() (map[string]interface{}, error)

func (*Instance) GetValue

func (inst *Instance) GetValue(name string) (value interface{}, exists bool)

func (*Instance) ID

func (inst *Instance) ID() string

func (*Instance) IOMetadata

func (inst *Instance) IOMetadata() *metadata.IOMetadata

IOMetadata get the input/output metadata of the activity host

func (*Instance) Logger

func (inst *Instance) Logger() log.Logger

func (*Instance) MarshalJSON

func (inst *Instance) MarshalJSON() ([]byte, error)

MarshalJSON overrides the default MarshalJSON for FlowInstance

func (*Instance) Name

func (inst *Instance) Name() string

func (*Instance) Reply

func (inst *Instance) Reply(replyData map[string]interface{}, err error)

func (*Instance) Return

func (inst *Instance) Return(returnData map[string]interface{}, err error)

func (*Instance) Scope

func (inst *Instance) Scope() data.Scope

func (*Instance) SetResultHandler

func (inst *Instance) SetResultHandler(handler action.ResultHandler)

InitActionContext initialize the action context, should be initialized before execution

func (*Instance) SetStatus

func (inst *Instance) SetStatus(status model.FlowStatus)

func (*Instance) SetValue

func (inst *Instance) SetValue(name string, value interface{}) error

func (*Instance) SpanConfig

func (inst *Instance) SpanConfig() trace.Config

func (*Instance) Status

func (inst *Instance) Status() model.FlowStatus

Status returns the current status of the Flow Instance

func (*Instance) TaskInstances

func (inst *Instance) TaskInstances() []model.TaskInstance

TaskInstances get the task instances

func (*Instance) TracingContext

func (inst *Instance) TracingContext() trace.TracingContext

func (*Instance) UnmarshalJSON

func (inst *Instance) UnmarshalJSON(d []byte) error

UnmarshalJSON overrides the default UnmarshalJSON for FlowInstance

func (*Instance) UpdateAttrs

func (inst *Instance) UpdateAttrs(attrs map[string]interface{})

UpdateAttrs updates the attributes of the Flow Instance

type LegacyCtx

type LegacyCtx struct {
	// contains filtered or unexported fields
}

DEPRECATED

func (*LegacyCtx) ActivityHost

func (l *LegacyCtx) ActivityHost() activity.Host

func (*LegacyCtx) GetInput

func (l *LegacyCtx) GetInput(name string) interface{}

func (*LegacyCtx) GetInputObject

func (l *LegacyCtx) GetInputObject(input data.StructValue) error

func (*LegacyCtx) GetInputSchema

func (l *LegacyCtx) GetInputSchema(name string) schema.Schema

func (*LegacyCtx) GetOutput

func (l *LegacyCtx) GetOutput(name string) interface{}

func (*LegacyCtx) GetOutputSchema

func (l *LegacyCtx) GetOutputSchema(name string) schema.Schema

func (*LegacyCtx) GetSetting

func (l *LegacyCtx) GetSetting(name string) (interface{}, bool)

func (*LegacyCtx) GetSharedTempData

func (l *LegacyCtx) GetSharedTempData() map[string]interface{}

func (*LegacyCtx) GetTracingContext

func (l *LegacyCtx) GetTracingContext() trace.TracingContext

func (*LegacyCtx) Logger

func (l *LegacyCtx) Logger() log.Logger

func (*LegacyCtx) Name

func (l *LegacyCtx) Name() string

func (*LegacyCtx) SetOutput

func (l *LegacyCtx) SetOutput(name string, value interface{}) error

func (*LegacyCtx) SetOutputObject

func (l *LegacyCtx) SetOutputObject(output data.StructValue) error

type LinkInst

type LinkInst struct {
	// contains filtered or unexported fields
}

LinkInst represents data associated with an instance of a Link

func NewLinkInst

func NewLinkInst(inst *Instance, link *definition.Link) *LinkInst

NewLinkInst creates a LinkInst for the specified link in the specified task environment

func (li *LinkInst) Link() *definition.Link

Link returns the Link associated with ld context

func (*LinkInst) MarshalJSON

func (li *LinkInst) MarshalJSON() ([]byte, error)

MarshalJSON overrides the default MarshalJSON for LinkInst

func (*LinkInst) SetStatus

func (li *LinkInst) SetStatus(status model.LinkStatus)

SetStatus sets the current state indicator for the LinkInst

func (*LinkInst) Status

func (li *LinkInst) Status() model.LinkStatus

Status returns the current state indicator for the LinkInst

func (*LinkInst) UnmarshalJSON

func (li *LinkInst) UnmarshalJSON(d []byte) error

UnmarshalJSON overrides the default UnmarshalJSON for LinkInst

type NoopChangeTracker

type NoopChangeTracker struct {
}

func (*NoopChangeTracker) AttrChange

func (nct *NoopChangeTracker) AttrChange(subflowId int, name string, value interface{})

func (*NoopChangeTracker) ExtractStep

func (nct *NoopChangeTracker) ExtractStep(reset bool) *state.Step

func (*NoopChangeTracker) FlowCreated

func (nct *NoopChangeTracker) FlowCreated(flow *IndependentInstance)

func (*NoopChangeTracker) FlowDone

func (nct *NoopChangeTracker) FlowDone(flow *IndependentInstance)

func (*NoopChangeTracker) LinkAdded

func (nct *NoopChangeTracker) LinkAdded(linkInst *LinkInst)

func (*NoopChangeTracker) LinkRemoved

func (nct *NoopChangeTracker) LinkRemoved(subflowId int, linkId int)

func (*NoopChangeTracker) LinkUpdated

func (nct *NoopChangeTracker) LinkUpdated(linkInst *LinkInst)

func (*NoopChangeTracker) SetStatus

func (nct *NoopChangeTracker) SetStatus(subflowId int, status model.FlowStatus)

func (*NoopChangeTracker) SubflowCreated

func (nct *NoopChangeTracker) SubflowCreated(subflow *Instance)

func (*NoopChangeTracker) SubflowDone

func (nct *NoopChangeTracker) SubflowDone(subflow *Instance)

func (*NoopChangeTracker) TaskAdded

func (nct *NoopChangeTracker) TaskAdded(taskInst *TaskInst)

func (*NoopChangeTracker) TaskRemoved

func (nct *NoopChangeTracker) TaskRemoved(subflowId int, taskId string)

func (*NoopChangeTracker) TaskUpdated

func (nct *NoopChangeTracker) TaskUpdated(taskInst *TaskInst)

func (*NoopChangeTracker) WorkItemAdded

func (nct *NoopChangeTracker) WorkItemAdded(wi *WorkItem)

func (*NoopChangeTracker) WorkItemRemoved

func (nct *NoopChangeTracker) WorkItemRemoved(wi *WorkItem)

type RunOptions

type RunOptions struct {
	Op                  int
	ReturnID            bool
	FlowURI             string
	PreservedInstanceId string
	InitStepId          int
	InitialState        *IndependentInstance
	ExecOptions         *ExecOptions
	Rerun               bool
	OriginalInstanceId  string
}

RunOptions the options when running a FlowAction

type SimpleChangeTracker

type SimpleChangeTracker struct {
	// contains filtered or unexported fields
}

func (*SimpleChangeTracker) AttrChange

func (sct *SimpleChangeTracker) AttrChange(subflowId int, name string, value interface{})

func (*SimpleChangeTracker) ExtractStep

func (sct *SimpleChangeTracker) ExtractStep(reset bool) *state.Step

func (*SimpleChangeTracker) FlowCreated

func (sct *SimpleChangeTracker) FlowCreated(flow *IndependentInstance)

func (*SimpleChangeTracker) FlowDone

func (sct *SimpleChangeTracker) FlowDone(flow *IndependentInstance)

func (*SimpleChangeTracker) LinkAdded

func (sct *SimpleChangeTracker) LinkAdded(linkInst *LinkInst)

func (*SimpleChangeTracker) LinkRemoved

func (sct *SimpleChangeTracker) LinkRemoved(subflowId int, linkId int)

func (*SimpleChangeTracker) LinkUpdated

func (sct *SimpleChangeTracker) LinkUpdated(linkInst *LinkInst)

func (*SimpleChangeTracker) SetStatus

func (sct *SimpleChangeTracker) SetStatus(subflowId int, status model.FlowStatus)

func (*SimpleChangeTracker) SubflowCreated

func (sct *SimpleChangeTracker) SubflowCreated(subflow *Instance)

func (*SimpleChangeTracker) SubflowDone

func (sct *SimpleChangeTracker) SubflowDone(subflow *Instance)

func (*SimpleChangeTracker) TaskAdded

func (sct *SimpleChangeTracker) TaskAdded(taskInst *TaskInst)

func (*SimpleChangeTracker) TaskRemoved

func (sct *SimpleChangeTracker) TaskRemoved(subflowId int, taskId string)

func (*SimpleChangeTracker) TaskUpdated

func (sct *SimpleChangeTracker) TaskUpdated(taskInst *TaskInst)

func (*SimpleChangeTracker) WorkItemAdded

func (sct *SimpleChangeTracker) WorkItemAdded(wi *WorkItem)

func (*SimpleChangeTracker) WorkItemRemoved

func (sct *SimpleChangeTracker) WorkItemRemoved(wi *WorkItem)

type SimpleChangeTrackerFactory

type SimpleChangeTrackerFactory struct {
}

func (*SimpleChangeTrackerFactory) NewChangeTracker

func (sf *SimpleChangeTrackerFactory) NewChangeTracker(flowId string, mode state.RecordingMode, startStepId int) ChangeTracker

type TaskInst

type TaskInst struct {
	// contains filtered or unexported fields
}

func NewTaskInst

func NewTaskInst(flowInst *Instance, task *definition.Task) *TaskInst

func (*TaskInst) ActivityHost

func (ti *TaskInst) ActivityHost() activity.Host

func (*TaskInst) EvalActivity

func (ti *TaskInst) EvalActivity() (done bool, evalErr error)

EvalActivity implements activity.ActivityContext.EvalActivity method

func (ti *TaskInst) EvalLink(link *definition.Link) (result bool, err error)

EvalLink implements activity.ActivityContext.EvalLink method

func (*TaskInst) FlowLogger

func (ti *TaskInst) FlowLogger() log.Logger

func (*TaskInst) GetFromLinkInstances

func (ti *TaskInst) GetFromLinkInstances() []model.LinkInstance

GetFromLinkInstances implements model.TaskContext.GetFromLinkInstances

func (*TaskInst) GetInput

func (ti *TaskInst) GetInput(name string) interface{}

GetInput implements activity.Context.GetInput

func (*TaskInst) GetInputObject

func (ti *TaskInst) GetInputObject(input data.StructValue) error

GetInputObject implements activity.Context.GetInputObject

func (*TaskInst) GetInputSchema

func (ti *TaskInst) GetInputSchema(name string) schema.Schema

func (*TaskInst) GetOutputSchema

func (ti *TaskInst) GetOutputSchema(name string) schema.Schema

func (*TaskInst) GetSetting

func (ti *TaskInst) GetSetting(name string) (value interface{}, exists bool)

func (*TaskInst) GetSharedTempData

func (ti *TaskInst) GetSharedTempData() map[string]interface{}

func (*TaskInst) GetToLinkInstances

func (ti *TaskInst) GetToLinkInstances() []model.LinkInstance

GetToLinkInstances implements model.TaskContext.GetToLinkInstances,

func (*TaskInst) GetTracingContext

func (ti *TaskInst) GetTracingContext() trace.TracingContext

GetInputObject implements activity.Context.GetInputObject

func (*TaskInst) GetWorkingData

func (ti *TaskInst) GetWorkingData(key string) (interface{}, bool)

func (*TaskInst) GetWorkingDataScope

func (ti *TaskInst) GetWorkingDataScope() *WorkingDataScope

func (*TaskInst) HasActivity

func (ti *TaskInst) HasActivity() bool

HasActivity implements activity.ActivityContext.HasActivity method

func (*TaskInst) InstanceId

func (ti *TaskInst) InstanceId() string

Returns task instance id

func (*TaskInst) Logger

func (ti *TaskInst) Logger() log.Logger

func (*TaskInst) MarshalJSON

func (ti *TaskInst) MarshalJSON() ([]byte, error)

MarshalJSON overrides the default MarshalJSON for TaskInst

func (*TaskInst) Name

func (ti *TaskInst) Name() string

Name implements activity.Context.Name method

func (*TaskInst) PostEvalActivity

func (ti *TaskInst) PostEvalActivity() (done bool, evalErr error)

EvalActivity implements activity.ActivityContext.EvalActivity method

func (*TaskInst) SetOutput

func (ti *TaskInst) SetOutput(name string, value interface{}) error

SetOutput implements activity.Context.SetOutput

func (*TaskInst) SetOutputObject

func (ti *TaskInst) SetOutputObject(output data.StructValue) error

SetOutputObject implements activity.Context.SetOutputObject

func (*TaskInst) SetOutputs

func (ti *TaskInst) SetOutputs(outputs map[string]interface{}) error

func (*TaskInst) SetStatus

func (ti *TaskInst) SetStatus(status model.TaskStatus)

SetStatus implements flow.TaskContext.SetStatus

func (*TaskInst) SetWorkingData

func (ti *TaskInst) SetWorkingData(key string, value interface{})

func (*TaskInst) SpanConfig

func (ti *TaskInst) SpanConfig() trace.Config

func (*TaskInst) Status

func (ti *TaskInst) Status() model.TaskStatus

Status implements flow.TaskContext.GetState

func (*TaskInst) Task

func (ti *TaskInst) Task() *definition.Task

Task implements model.TaskContext.Task, by returning the Task associated with this TaskInst object

func (*TaskInst) UnmarshalJSON

func (ti *TaskInst) UnmarshalJSON(d []byte) error

UnmarshalJSON overrides the default UnmarshalJSON for TaskInst

func (*TaskInst) UpdateTaskToTracker

func (ti *TaskInst) UpdateTaskToTracker()

UpdateTaskToTracker update task to tracker

type WorkItem

type WorkItem struct {
	ID int `json:"id"`

	TaskID    string `json:"taskID"`
	SubFlowID int    `json:"subFlowId"`
	// contains filtered or unexported fields
}

WorkItem describes an item of work (event for a Task) that should be executed on Step

func NewWorkItem

func NewWorkItem(id int, taskInst *TaskInst) *WorkItem

NewWorkItem constructs a new WorkItem for the specified TaskInst

type WorkingDataScope

type WorkingDataScope struct {
	// contains filtered or unexported fields
}

func NewWorkingDataScope

func NewWorkingDataScope(parentScope data.Scope) *WorkingDataScope

NewWorkingDataScope

func (*WorkingDataScope) GetValue

func (s *WorkingDataScope) GetValue(name string) (value interface{}, exists bool)

func (*WorkingDataScope) GetWorkingValue

func (s *WorkingDataScope) GetWorkingValue(name string) (value interface{}, exists bool)

func (*WorkingDataScope) SetValue

func (s *WorkingDataScope) SetValue(name string, value interface{}) error

func (*WorkingDataScope) SetWorkingValue

func (s *WorkingDataScope) SetWorkingValue(name string, value interface{})

Jump to

Keyboard shortcuts

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