// 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 }
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()) } } }
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...) }
// 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) }
// 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) }
// 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) }
// 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) }
// 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 }
// 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) }
// 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()) }