Skip to content

Commit 222e0cb

Browse files
longquanzhengGroxx
authored andcommitted
Add DecisionTaskStartedEventID to workflowInfo (#1127)
1 parent 982628d commit 222e0cb

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
@@ -814,6 +814,8 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent(
814814
// Set replay clock.
815815
weh.SetCurrentReplayTime(time.Unix(0, event.GetTimestamp()))
816816
weh.workflowDefinition.OnDecisionTaskStarted()
817+
// Set replay decisionStarted eventID
818+
weh.workflowInfo.DecisionStartedEventID = event.GetEventId()
817819

818820
case m.EventTypeDecisionTaskTimedOut:
819821
// No Operation

internal/workflow.go

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

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

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

0 commit comments

Comments
 (0)