示例#1
0
文件: fsm.go 项目: iancoffey/swfsm
// signals the poller to stop reading decision task pages once we have marker events
func (f *FSM) taskReady(task *swf.PollForDecisionTaskOutput) bool {
	var state, correlator, prev bool
	for _, e := range task.Events {
		if f.isStateMarker(e) {
			state = true
		}

		if f.isCorrelatorMarker(e) {
			correlator = true
		}

		if *e.EventId <= *task.PreviousStartedEventId {
			prev = true
		}

		if state && correlator && prev {
			f.log("workflow=%q fn=taskReady at=state-and-correlator-and-prev-found eventid=%s",
				s.LS(task.WorkflowExecution.WorkflowId), s.LL(e.EventId))
			return true
		}

		if e.EventType != nil && *e.EventType == swf.EventTypeWorkflowExecutionStarted {
			f.log("workflow=%q fn=taskReady at=start-event eventid=%s",
				s.LS(task.WorkflowExecution.WorkflowId), s.LL(e.EventId))
			return true
		}
	}
	return false
}
示例#2
0
文件: fsm.go 项目: chadqueen/swfsm
func (f *FSM) handleDecisionTask(decisionTask *swf.PollForDecisionTaskOutput) {
	context, decisions, state, err := f.Tick(decisionTask)
	if err != nil {
		f.log("workflow=%s workflow-id=%s run-id=%s action=tick at=tick-error status=abandoning-task error=%q", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), s.LS(decisionTask.WorkflowExecution.RunId), err.Error())
		return
	}
	complete := &swf.RespondDecisionTaskCompletedInput{
		Decisions: decisions,
		TaskToken: decisionTask.TaskToken,
	}

	complete.ExecutionContext = aws.String(state.StateName)

	if _, err := f.SWF.RespondDecisionTaskCompleted(complete); err != nil {
		f.log("workflow=%s workflow-id=%s action=tick at=decide-request-failed error=%q", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), s.LS(decisionTask.WorkflowExecution.RunId), err.Error())
		return
	}

	if f.ReplicationHandler != nil {
		repErr := f.ReplicationHandler(context, decisionTask, complete, state)
		if repErr != nil {
			f.log("workflow=%s workflow-id=%s action=tick at=replication-handler-failed error=%q", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), s.LS(decisionTask.WorkflowExecution.RunId), repErr.Error())
		}
	}

}
示例#3
0
文件: fsm.go 项目: iancoffey/swfsm
func (f *FSM) clog(ctx *FSMContext, format string, data ...interface{}) {
	actualFormat := fmt.Sprintf("component=FSM name=%s type=%s id=%s %s", f.Name, s.LS(ctx.WorkflowType.Name), s.LS(ctx.WorkflowId), format)
	Log.Printf(actualFormat, data...)
}
示例#4
0
文件: fsm.go 项目: iancoffey/swfsm
// ErrorSerializingStateData is part of the FSM implementation of FSMErrorReporter
func (f *FSM) ErrorSerializingStateData(decisionTask *swf.PollForDecisionTaskOutput, outcome Outcome, eventCorrelator EventCorrelator, err error) {
	f.log("action=tick workflow=%s workflow-id=%s at=error error=state-serialization-error err=%q error-type=system", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), err)

}
示例#5
0
文件: fsm.go 项目: iancoffey/swfsm
// ErrorDeserializingStateData is part of the FSM implementation of FSMErrorReporter
func (f *FSM) ErrorDeserializingStateData(decisionTask *swf.PollForDecisionTaskOutput, serializedStateData string, err error) {
	f.log("action=tick workflow=%s workflow-id=%s at=error=deserialize-state-failed err=&s", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), err)
}
示例#6
0
文件: fsm.go 项目: iancoffey/swfsm
// ErrorMissingFSMState is part of the FSM implementation of FSMErrorReporter
func (f *FSM) ErrorMissingFSMState(decisionTask *swf.PollForDecisionTaskOutput, outcome Outcome) {
	f.log("action=tick workflow=%s workflow-id=%s at=error error=marked-state-not-in-fsm state=%s", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), outcome.State)
}
示例#7
0
文件: fsm.go 项目: iancoffey/swfsm
// ErrorFindingCorrelator is part of the FSM implementation of FSMErrorReporter
func (f *FSM) ErrorFindingCorrelator(decisionTask *swf.PollForDecisionTaskOutput, err error) {
	f.log("action=tick workflow=%s workflow-id=%s at=error=find-serialized-event-correlator-failed err=%q", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), err)
}
示例#8
0
文件: fsm.go 项目: iancoffey/swfsm
// DefaultDecisionErrorHandler is the DefaultDecisionErrorHandler
func (f *FSM) DefaultDecisionErrorHandler(ctx *FSMContext, event *swf.HistoryEvent, stateBeforeEvent interface{}, stateAfterError interface{}, err error) (*Outcome, error) {
	f.log("action=tick workflow=%s workflow-id=%s at=decider-error err=%q", s.LS(ctx.WorkflowType.Name), s.LS(ctx.WorkflowId), err)
	return nil, err
}
示例#9
0
文件: fsm.go 项目: ryanwalls/swfsm
// ErrorFindingStateData is part of the FSM implementation of FSMErrorReporter
func (f *FSM) ErrorFindingStateData(decisionTask *swf.PollForDecisionTaskOutput, err error) {
	f.log("action=tick workflow=%s workflow-id=%s at=find-serialized-state-failed error=%q", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), err)
}
示例#10
0
文件: fsm.go 项目: ryanwalls/swfsm
// DefaultTaskErrorHandler is the default TaskErrorHandler that is used if a
// TaskErrorHandler is not set on this FSM.  DefaultTaskErrorHandler simply logs the error.
// With no further intervention the decision task will timeout.
func (f *FSM) DefaultTaskErrorHandler(decisionTask *swf.PollForDecisionTaskOutput, err error) {
	f.log("workflow=%s workflow-id=%s run-id=%s action=tick at=handle-task-error status=abandoning-task error=%q", s.LS(decisionTask.WorkflowType.Name), s.LS(decisionTask.WorkflowExecution.WorkflowId), s.LS(decisionTask.WorkflowExecution.RunId), err.Error())
}