Skip to content

Commit de8f006

Browse files
authored
Update Registry suggest CAN refactor (temporalio#7230)
## What changed? <!-- Describe what has changed in this PR --> Refactoring to allow Update registry to allow suggesting CAN. ## Why? <!-- Tell your future self why have you made these changes --> Preparation for implementation. "Make the change easy, then make the easy change". ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) -->
1 parent 1b11ed2 commit de8f006

File tree

15 files changed

+51
-6
lines changed

15 files changed

+51
-6
lines changed

service/history/api/create_workflow_util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func NewWorkflowWithSignal(
136136
startRequest.StartRequest.Identity,
137137
nil,
138138
nil,
139+
nil,
139140
false,
140141
)
141142
if err != nil {

service/history/api/recordworkflowtaskstarted/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ func Invoke(
182182
req.PollRequest.Identity,
183183
worker_versioning.StampFromCapabilities(req.PollRequest.WorkerVersionCapabilities),
184184
req.GetBuildIdRedirectInfo(),
185+
workflowLease.GetContext().UpdateRegistry(ctx),
185186
false,
186187
)
187188
if err != nil {

service/history/api/respondworkflowtaskcompleted/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ func (handler *WorkflowTaskCompletedHandler) Invoke(
561561
request.Identity,
562562
versioningStamp,
563563
nil,
564+
workflowLease.GetContext().UpdateRegistry(ctx),
564565
false,
565566
)
566567
if err != nil {
@@ -683,6 +684,7 @@ func (handler *WorkflowTaskCompletedHandler) Invoke(
683684
request.Identity,
684685
versioningStamp,
685686
nil,
687+
workflowLease.GetContext().UpdateRegistry(ctx),
686688
false,
687689
)
688690
if err != nil {

service/history/api/respondworkflowtaskcompleted/api_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ func (s *WorkflowTaskCompletedHandlerSuite) createSentUpdate(tv *testvars.TestVa
595595
tv.Any().String(),
596596
nil,
597597
nil,
598+
nil,
598599
false,
599600
)
600601
taskToken := &tokenspb.Task{

service/history/api/verifyfirstworkflowtaskscheduled/api_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ func (s *VerifyFirstWorkflowTaskScheduledSuite) TestVerifyFirstWorkflowTaskSched
257257
uuid.New(),
258258
nil,
259259
nil,
260+
nil,
260261
false,
261262
)
262263
wt.StartedEventID = workflowTasksStartEvent.GetEventId()

service/history/history_engine_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6332,6 +6332,7 @@ func addWorkflowTaskStartedEventWithRequestID(ms workflow.MutableState, schedule
63326332
identity,
63336333
nil,
63346334
nil,
6335+
nil,
63356336
false,
63366337
)
63376338

service/history/ndc/workflow_resetter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ func (r *workflowResetterImpl) failWorkflowTask(
533533
consts.IdentityHistoryService,
534534
nil,
535535
nil,
536+
nil,
536537
// skipping versioning checks because this task is not actually dispatched but will fail immediately.
537538
true,
538539
)

service/history/ndc/workflow_resetter_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ func (s *workflowResetterSuite) TestFailWorkflowTask_WorkflowTaskScheduled() {
400400
consts.IdentityHistoryService,
401401
nil,
402402
nil,
403+
nil,
403404
true,
404405
).Return(&historypb.HistoryEvent{}, workflowTaskStart, nil)
405406
mutableState.EXPECT().AddWorkflowTaskFailedEvent(
@@ -1469,6 +1470,7 @@ func (s *workflowResetterSuite) TestWorkflowRestartAfterExecutionTimeout() {
14691470
consts.IdentityHistoryService,
14701471
nil,
14711472
nil,
1473+
nil,
14721474
true,
14731475
).Return(&historypb.HistoryEvent{}, workflowTaskStart, nil)
14741476

service/history/workflow/mutable_state.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import (
5454
"go.temporal.io/server/service/history/historybuilder"
5555
"go.temporal.io/server/service/history/hsm"
5656
"go.temporal.io/server/service/history/tasks"
57+
"go.temporal.io/server/service/history/workflow/update"
5758
"google.golang.org/protobuf/types/known/durationpb"
5859
"google.golang.org/protobuf/types/known/timestamppb"
5960
)
@@ -182,7 +183,7 @@ type (
182183
AddFirstWorkflowTaskScheduled(parentClock *clockspb.VectorClock, event *historypb.HistoryEvent, bypassTaskGeneration bool) (int64, error)
183184
AddWorkflowTaskScheduledEvent(bypassTaskGeneration bool, workflowTaskType enumsspb.WorkflowTaskType) (*WorkflowTaskInfo, error)
184185
AddWorkflowTaskScheduledEventAsHeartbeat(bypassTaskGeneration bool, originalScheduledTimestamp *timestamppb.Timestamp, workflowTaskType enumsspb.WorkflowTaskType) (*WorkflowTaskInfo, error)
185-
AddWorkflowTaskStartedEvent(int64, string, *taskqueuepb.TaskQueue, string, *commonpb.WorkerVersionStamp, *taskqueuespb.BuildIdRedirectInfo, bool) (*historypb.HistoryEvent, *WorkflowTaskInfo, error)
186+
AddWorkflowTaskStartedEvent(int64, string, *taskqueuepb.TaskQueue, string, *commonpb.WorkerVersionStamp, *taskqueuespb.BuildIdRedirectInfo, update.Registry, bool) (*historypb.HistoryEvent, *WorkflowTaskInfo, error)
186187
AddWorkflowTaskTimedOutEvent(workflowTask *WorkflowTaskInfo) (*historypb.HistoryEvent, error)
187188
AddExternalWorkflowExecutionCancelRequested(int64, namespace.Name, namespace.ID, string, string) (*historypb.HistoryEvent, error)
188189
AddExternalWorkflowExecutionSignaled(int64, namespace.Name, namespace.ID, string, string, string) (*historypb.HistoryEvent, error)

service/history/workflow/mutable_state_impl.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import (
8686
"go.temporal.io/server/service/history/hsm"
8787
"go.temporal.io/server/service/history/shard"
8888
"go.temporal.io/server/service/history/tasks"
89+
"go.temporal.io/server/service/history/workflow/update"
8990
"google.golang.org/protobuf/proto"
9091
"google.golang.org/protobuf/types/known/durationpb"
9192
"google.golang.org/protobuf/types/known/timestamppb"
@@ -2607,13 +2608,14 @@ func (ms *MutableStateImpl) AddWorkflowTaskStartedEvent(
26072608
identity string,
26082609
versioningStamp *commonpb.WorkerVersionStamp,
26092610
redirectInfo *taskqueuespb.BuildIdRedirectInfo,
2611+
updateReg update.Registry,
26102612
skipVersioningCheck bool,
26112613
) (*historypb.HistoryEvent, *WorkflowTaskInfo, error) {
26122614
opTag := tag.WorkflowActionWorkflowTaskStarted
26132615
if err := ms.checkMutability(opTag); err != nil {
26142616
return nil, nil, err
26152617
}
2616-
return ms.workflowTaskManager.AddWorkflowTaskStartedEvent(scheduledEventID, requestID, taskQueue, identity, versioningStamp, redirectInfo, skipVersioningCheck)
2618+
return ms.workflowTaskManager.AddWorkflowTaskStartedEvent(scheduledEventID, requestID, taskQueue, identity, versioningStamp, redirectInfo, skipVersioningCheck, updateReg)
26172619
}
26182620

26192621
func (ms *MutableStateImpl) ApplyWorkflowTaskStartedEvent(

0 commit comments

Comments
 (0)