Skip to content

Commit 9fdc4bc

Browse files
Add DecisionTaskStartedEventID to workflowInfo (#1127)
1 parent 9c3efae commit 9fdc4bc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

internal/internal_event_handlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,8 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent(
818818
// Set replay clock.
819819
weh.SetCurrentReplayTime(time.Unix(0, event.GetTimestamp()))
820820
weh.workflowDefinition.OnDecisionTaskStarted()
821+
// Set replay decisionStarted eventID
822+
weh.workflowInfo.DecisionStartedEventID = event.GetEventId()
821823

822824
case m.EventTypeDecisionTaskTimedOut:
823825
// No Operation

internal/workflow.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,18 +793,26 @@ type WorkflowInfo struct {
793793
ParentWorkflowExecution *WorkflowExecution
794794
Memo *s.Memo // Value can be decoded using data converter (DefaultDataConverter, or custom one if set).
795795
SearchAttributes *s.SearchAttributes // Value can be decoded using DefaultDataConverter.
796-
BinaryChecksum *string
796+
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)
797+
DecisionStartedEventID int64 // the eventID of DecisionStarted that is making the current decision(can be used for reset API)
797798
RetryPolicy *s.RetryPolicy
798799
}
799800

800801
// GetBinaryChecksum returns the binary checksum(identifier) of this worker
802+
// 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)
803+
// In replay mode, it's from DecisionTaskCompleted event. In non-replay mode, it's from the currently executing worker.
801804
func (wInfo *WorkflowInfo) GetBinaryChecksum() string {
802805
if wInfo.BinaryChecksum == nil {
803806
return getBinaryChecksum()
804807
}
805808
return *wInfo.BinaryChecksum
806809
}
807810

811+
// GetDecisionCompletedEventID returns the eventID of DecisionStartedEvent that is making the current decision(can be used for reset API: decisionFinishEventID = DecisionStartedEventID + 1)
812+
func (wInfo *WorkflowInfo) GetDecisionStartedEventID() int64 {
813+
return wInfo.DecisionStartedEventID
814+
}
815+
808816
// GetWorkflowInfo extracts info of a current workflow from a context.
809817
func GetWorkflowInfo(ctx Context) *WorkflowInfo {
810818
i := getWorkflowInterceptor(ctx)

0 commit comments

Comments
 (0)