Skip to content

Commit

Permalink
Add DecisionTaskStartedEventID to workflowInfo (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng committed Sep 10, 2021
1 parent 9c3efae commit 9fdc4bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/internal_event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,8 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent(
// Set replay clock.
weh.SetCurrentReplayTime(time.Unix(0, event.GetTimestamp()))
weh.workflowDefinition.OnDecisionTaskStarted()
// Set replay decisionStarted eventID
weh.workflowInfo.DecisionStartedEventID = event.GetEventId()

case m.EventTypeDecisionTaskTimedOut:
// No Operation
Expand Down
10 changes: 9 additions & 1 deletion internal/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,18 +793,26 @@ type WorkflowInfo struct {
ParentWorkflowExecution *WorkflowExecution
Memo *s.Memo // Value can be decoded using data converter (DefaultDataConverter, or custom one if set).
SearchAttributes *s.SearchAttributes // Value can be decoded using DefaultDataConverter.
BinaryChecksum *string
BinaryChecksum *string // The identifier(generated by md5sum by default) of worker code that is making the current decision(can be used for auto-reset feature)
DecisionStartedEventID int64 // the eventID of DecisionStarted that is making the current decision(can be used for reset API)
RetryPolicy *s.RetryPolicy
}

// GetBinaryChecksum returns the binary checksum(identifier) of this worker
// It is the identifier(generated by md5sum by default) of worker code that is making the current decision(can be used for auto-reset feature)
// In replay mode, it's from DecisionTaskCompleted event. In non-replay mode, it's from the currently executing worker.
func (wInfo *WorkflowInfo) GetBinaryChecksum() string {
if wInfo.BinaryChecksum == nil {
return getBinaryChecksum()
}
return *wInfo.BinaryChecksum
}

// GetDecisionCompletedEventID returns the eventID of DecisionStartedEvent that is making the current decision(can be used for reset API: decisionFinishEventID = DecisionStartedEventID + 1)
func (wInfo *WorkflowInfo) GetDecisionStartedEventID() int64 {
return wInfo.DecisionStartedEventID
}

// GetWorkflowInfo extracts info of a current workflow from a context.
func GetWorkflowInfo(ctx Context) *WorkflowInfo {
i := getWorkflowInterceptor(ctx)
Expand Down

0 comments on commit 9fdc4bc

Please sign in to comment.