Skip to content

Commit 18ea071

Browse files
committed
use ArchetypeID for tasks
1 parent 1f2f04a commit 18ea071

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

service/history/queues/executable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var (
8787
taskResourceExhuastedReschedulePolicy = common.CreateTaskResourceExhaustedReschedulePolicy()
8888
dependencyTaskNotCompletedReschedulePolicy = common.CreateDependencyTaskNotCompletedReschedulePolicy()
8989

90-
_ MaybeTerminalTaskError = (*terminalTaskError)(nil)
90+
_ MaybeTerminalTaskError = terminalTaskError{}
9191
)
9292

9393
const (

service/history/timer_queue_active_task_executor.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,14 @@ func (t *timerQueueActiveTaskExecutor) executeTimeSkippingTimerTask(
928928
return consts.ErrWorkflowExecutionNotFound
929929
}
930930

931-
// todo@time-skipping: chasm execution path is not implemented yet.
932-
if !mutableState.IsWorkflow() {
931+
// Route by execution archetype. Treat an unspecified archetype — a record persisted before
932+
// archetype IDs existed, or a not-yet-initialized chasm tree — as the built-in workflow archetype.
933+
archetypeID := mutableState.ChasmTree().ArchetypeID()
934+
if archetypeID == chasm.UnspecifiedArchetypeID {
935+
archetypeID = chasm.WorkflowArchetypeID
936+
}
937+
if archetypeID != chasm.WorkflowArchetypeID {
938+
// TODO@time-skipping: chasm execution path is not implemented yet.
933939
release(nil)
934940
return nil
935941
}

service/history/workflow/timeskipping.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ func (ms *MutableStateImpl) applyFastForward(propagatedTargetTime *timestamppb.T
8383
targetTime = ms.Now().Add(tsc.GetFastForward().AsDuration())
8484
}
8585

86-
currentVersionedTransition := ms.CurrentVersionedTransition()
86+
currentVersionedTransition := &persistencespb.VersionedTransition{
87+
NamespaceFailoverVersion: ms.GetCurrentVersion(),
88+
TransitionCount: ms.NextTransitionCount(),
89+
}
90+
8791
tsi.FastForwardInfo = &persistencespb.FastForwardInfo{
8892
TargetTime: timestamppb.New(targetTime),
8993
HasReached: false,
@@ -269,12 +273,27 @@ func NewTimeSkippingInfoUtil(tsi *persistencespb.TimeSkippingInfo) *TimeSkipping
269273
return &TimeSkippingInfoUtil{tsi: tsi}
270274
}
271275

276+
// HasPendingFastForward reports whether time skipping is enabled and carries a fast-forward that has
277+
// not yet been reached and has a real (non-zero) target time. A fast-forward on a disabled config is
278+
// not "pending" because it can never fire. All accesses go through nil-safe proto getters, so a nil
279+
// util, nil info, nil config, or nil fast-forward all yield false.
272280
func (util *TimeSkippingInfoUtil) HasPendingFastForward() bool {
273-
return util.tsi != nil && util.tsi.GetFastForwardInfo() != nil && !util.tsi.GetFastForwardInfo().GetHasReached() &&
274-
util.tsi.GetFastForwardInfo().GetTargetTime() != nil && !util.tsi.GetFastForwardInfo().GetTargetTime().AsTime().IsZero()
281+
if util == nil || !util.IsEnabled() {
282+
return false
283+
}
284+
ff := util.tsi.GetFastForwardInfo()
285+
return ff != nil &&
286+
!ff.GetHasReached() &&
287+
ff.GetTargetTime() != nil &&
288+
!ff.GetTargetTime().AsTime().IsZero()
275289
}
276290

291+
// IsEnabled reports whether time skipping is enabled. Nil-safe: a nil util, nil info, or nil config
292+
// all yield false.
277293
func (util *TimeSkippingInfoUtil) IsEnabled() bool {
294+
if util == nil {
295+
return false
296+
}
278297
return util.tsi.GetConfig().GetEnabled()
279298
}
280299

0 commit comments

Comments
 (0)