timer_queue_task_executor_base.go ×6

Frontier kind: Code frontier

unlabeled · c_0bbb21388260

4 tests · 5168 LOC · 219 files · introduces 0 tests · 63 LOC · 5 files

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges63 lines · 5 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
830 ranges5168 lines · 219 files · Browse complete extent
All tests (intent)
4 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

5 files ranked by introduced lines: 63 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/timer_queue_task_executor_base.go 26 introduced LOC · 6 ranges

Open complete file

220 timer *persistencespb.StateMachineTaskInfo,
221 execute func(node *hsm.Node, task hsm.Task) error,
223 > def, ok := t.shardContext.StateMachineRegistry().TaskSerializer(timer.Type)
224 > if !ok {
225 return queueserrors.NewUnprocessableTaskError(fmt.Sprintf("deserializer not registered for task type %v", timer.Type))
226 }
227 > smt, err := def.Deserialize(timer.Data, hsm.TaskAttributes{Deadline: deadline}) timer_queue_task_executor_base.go
228 > if err != nil {
229 return fmt.Errorf(
230 "%w: %w",
233 )
234 }
235 > ref := hsm.Ref{ timer_queue_task_executor_base.go
236 > WorkflowKey: ms.GetWorkflowKey(),
237 > StateMachineRef: timer.Ref,
238 > Validate: smt.Validate,
239 > }
240 > // TODO(bergundy): Duplicated this logic from the Access method. We specify write access here because
241 > // validateNotZombieWorkflow only blocks write access to zombie workflows.
242 > if err := t.validateNotZombieWorkflow(ms, hsm.AccessWrite); err != nil {
243 return err
244 }
245 > if err := t.validateStateMachineRef(ctx, workflowContext, ms, ref, false); err != nil { timer_queue_task_executor_base.go
246 return err
247 }
304 }
305
306 > timers := ms.GetExecutionInfo().StateMachineTimers timer_queue_task_executor_base.go
307 > processedTimers := 0
308 >
309 > // StateMachineTimers are sorted by Deadline, iterate through them as long as the deadline is expired.
310 > for len(timers) > 0 {
311 > group := timers[0]
312 > if !queues.IsTimeExpired(task, t.Now(), ms.ToRealTime(group.Deadline.AsTime())) {
313 break
314 }
315
316 > for _, timer := range group.Infos { timer_queue_task_executor_base.go
317 > err := t.executeSingleStateMachineTimer(ctx, workflowContext, ms, group.Deadline.AsTime(), timer, execute)
318 > if err != nil {
319 > // This includes errors such as ErrStaleReference and ErrWorkflowCompleted.
320 > if !errors.As(err, new(*serviceerror.NotFound)) {
321 metrics.StateMachineTimerProcessingFailuresCounter.With(t.metricsHandler).Record(
322 1,
go.temporal.io/server/components/dummy/statemachine.go 17 introduced LOC · 5 ranges

Open complete file

17 var StateMachineType = "dummy.Dummy"
18
19 > func MachineCollection(tree *hsm.Node) hsm.Collection[*Dummy] { statemachine.go
20 > return hsm.NewCollection[*Dummy](tree, StateMachineType)
21 > }
22
23 // Dummy state machine.
30
31 // NewDummy creates a new callback in the STANDBY state from given params.
32 > func NewDummy() *Dummy { statemachine.go
33 > return &Dummy{
34 > CurrentState: State0,
35 > }
36 > }
37
38 func (sm *Dummy) State() State {
52 var _ hsm.StateMachineDefinition = stateMachineDefinition{}
53
54 > func (stateMachineDefinition) Type() string { statemachine.go
55 > return StateMachineType
56 > }
57
58 func (stateMachineDefinition) Deserialize(d []byte) (any, error) {
62 }
63
64 > func (stateMachineDefinition) Serialize(state any) ([]byte, error) { statemachine.go
65 > return json.Marshal(state)
66 > }
67
68 func (stateMachineDefinition) CompareState(s1, s2 any) (int, error) {
71 }
72
73 > func RegisterStateMachine(r *hsm.Registry) error { statemachine.go
74 > return r.RegisterMachine(stateMachineDefinition{})
75 > }
76
77 type Event0 struct{}
go.temporal.io/server/components/dummy/tasks.go 13 introduced LOC · 4 ranges

Open complete file

65 }
66
67 > func (t TimerTask) Validate(ref *persistencespb.StateMachineRef, node *hsm.Node) error { tasks.go
68 > if !t.concurrent {
69 > return hsm.ValidateNotTransitioned(ref, node)
70 > }
71 return nil
72 }
74 type TimerTaskSerializer struct{}
75
76 > func (TimerTaskSerializer) Deserialize(data []byte, attrs hsm.TaskAttributes) (hsm.Task, error) { tasks.go
77 > return TimerTask{deadline: attrs.Deadline, concurrent: len(data) > 0}, nil
78 > }
79
80 func (s TimerTaskSerializer) Serialize(task hsm.Task) ([]byte, error) {
90 }
91
92 > func RegisterTaskSerializers(reg *hsm.Registry) error { tasks.go
93 > if err := reg.RegisterTaskSerializer(
94 > TaskTypeImmediate,
95 > ImmediateTaskSerializer{},
96 > ); err != nil {
97 return err
98 }
99 > return reg.RegisterTaskSerializer(TaskTypeTimer, TimerTaskSerializer{}) tasks.go
100 }
go.temporal.io/server/service/history/queues/metrics.go 5 introduced LOC · 3 ranges

Open complete file

208 }
209
210 > func GetTimerStateMachineTaskTypeTagValue(taskType string, isActive bool) string { metrics.go
211 > var prefix string
212 > if isActive {
213 prefix = "TimerActive"
214 > } else { metrics.go
215 prefix = "TimerStandby"
216 }
217
218 > return prefix + "." + taskType metrics.go
219 }
220
go.temporal.io/server/service/history/hsm/tasks.go 2 introduced LOC · 1 range

Open complete file

55 // ValidateNotTransitioned returns a [consts.ErrStaleReference] if the machine has transitioned since the task was
56 // generated.
57 > func ValidateNotTransitioned(ref *persistencespb.StateMachineRef, node *Node) error { tasks.go
58 > if ref.MachineTransitionCount != node.InternalRepr().TransitionCount {
59 return fmt.Errorf("%w: state machine transitions (%d) != ref transitions (%d)", consts.ErrStaleReference, node.InternalRepr().TransitionCount, ref.MachineTransitionCount)
60 }