go.temporal.io/server/components/dummy/tasks.go

100 LOC · 19 covered · 81 uncovered · 6 ranges · 10 concepts · 2 introducers · 4 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filego.temporal.io/server/components/dummy/executors.go · 54 LOCdummy/executors.gogo.temporal.io/server/components/dummy/statemachine.go · 95 LOCdummy/statemachine.gogo.temporal.io/server/service/history/hsm/tasks.go · 81 LOChsm/tasks.gogo.temporal.io/server/service/history/queues/metrics.go · 246 LOCqueues/metrics.gogo.temporal.io/server/service/history/timer_queue_active_task_executor.go · 1180 LOChistory/timer_queue_acti…go.temporal.io/server/service/history/timer_queue_task_executor_base.go · 348 LOChistory/timer_queue_task…timer_queue_standby_task_executor.go ×2 · 6 introduced LOCtimer_queue_standby_task…TestExecuteStateMachineTimerTask_ValidConcurrentTaskIsKept · 0 introduced LOCTestExecuteStateMachineT…TestExecuteStateMachineTimerTask_StaleStateMachine · 0 introduced LOCTestExecuteStateMachineT…statemachine.go ×3 · 9 introduced LOCstatemachine.go ×3timer_queue_standby_task_executor.go ×2 · 20 introduced LOCtimer_queue_standby_task…executors.go ×3 · 29 introduced LOCexecutors.go ×3metrics.go ×1 · 2 introduced LOCmetrics.go ×1timer_queue_task_executor_base.go ×5 · 15 introduced LOCtimer_queue_task_executo…timer_queue_task_executor_base.go ×2 · 4 introduced LOCtimer_queue_task_executo…timer_queue_task_executor_base.go ×6 · 63 introduced LOCtimer_queue_task_executo…TestExecuteStateMachineTimerTask_ExecutesAllAvailableTimers · introduced test · go.temporal.io/server/service/history/TestTimerQueueActiveTaskExecutorSuite/TestExecuteStateMachineTimerTask_ExecutesAllAvailableTimersTestExecuteStateMachineT…TestExecuteStateMachineTimerTask_ExecutesAllAvailableTimers · introduced test · go.temporal.io/server/service/history/TestTimerQueueStandbyTaskExecutorSuite/TestExecuteStateMachineTimerTask_ExecutesAllAvailableTimersTestExecuteStateMachineT…TestExecuteStateMachineTimerTask_StaleStateMachine · introduced test · go.temporal.io/server/service/history/TestTimerQueueStandbyTaskExecutorSuite/TestExecuteStateMachineTimerTask_StaleStateMachineTestExecuteStateMachineT…TestExecuteStateMachineTimerTask_ValidConcurrentTaskIsKept · introduced test · go.temporal.io/server/service/history/TestTimerQueueStandbyTaskExecutorSuite/TestExecuteStateMachineTimerTask_ValidConcurrentTaskIsKeptTestExecuteStateMachineT…Focused file · go.temporal.io/server/components/dummy/tasks.go · 100 LOCdummy/tasks.go

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package dummy
2
3 import (
4 "fmt"
5 "time"
6
7 persistencespb "go.temporal.io/server/api/persistence/v1"
8 "go.temporal.io/server/service/history/hsm"
9 )
10
11 const (
12 TaskTypeTimer = "dummy.Timer"
13 TaskTypeImmediate = "dummy.Immediate"
14 )
15
16 type ImmediateTask struct {
17 destination string
18 }
19
20 var _ hsm.Task = ImmediateTask{}
21
22 > func (ImmediateTask) Type() string { executors.go ×3
23 > return TaskTypeImmediate
24 > }
25
26 func (ImmediateTask) Deadline() time.Time {
27 return hsm.Immediate
28 }
29
30 func (t ImmediateTask) Destination() string {
31 return t.destination
32 }
33
34 func (ImmediateTask) Validate(ref *persistencespb.StateMachineRef, node *hsm.Node) error {
35 return hsm.ValidateNotTransitioned(ref, node)
36 }
37
38 type ImmediateTaskSerializer struct{}
39
40 func (ImmediateTaskSerializer) Deserialize(data []byte, attrs hsm.TaskAttributes) (hsm.Task, error) {
41 return ImmediateTask{destination: attrs.Destination}, nil
42 }
43
44 func (ImmediateTaskSerializer) Serialize(hsm.Task) ([]byte, error) {
45 return nil, nil
46 }
47
48 type TimerTask struct {
49 deadline time.Time
50 concurrent bool
51 }
52
53 var _ hsm.Task = TimerTask{}
54
55 > func (TimerTask) Type() string { executors.go ×3
56 > return TaskTypeTimer
57 > }
58
59 func (t TimerTask) Deadline() time.Time {
60 return t.deadline
61 }
62
63 func (TimerTask) Destination() string {
64 return ""
65 }
66
67 > func (t TimerTask) Validate(ref *persistencespb.StateMachineRef, node *hsm.Node) error { timer_queue_task_executor_base.go ×6
68 > if !t.concurrent {
69 > return hsm.ValidateNotTransitioned(ref, node)
70 > }
71 return nil
72 }
73
74 type TimerTaskSerializer struct{}
75
76 > func (TimerTaskSerializer) Deserialize(data []byte, attrs hsm.TaskAttributes) (hsm.Task, error) { timer_queue_task_executor_base.go ×6
77 > return TimerTask{deadline: attrs.Deadline, concurrent: len(data) > 0}, nil
78 > }
79
80 func (s TimerTaskSerializer) Serialize(task hsm.Task) ([]byte, error) {
81 if tt, ok := task.(TimerTask); ok {
82 if tt.concurrent {
83 // Non empty data marks the task as concurrent.
84 return []byte{1}, nil
85 }
86 // No-op.
87 return nil, nil
88 }
89 return nil, fmt.Errorf("incompatible task: %v", task)
90 }
91
92 > func RegisterTaskSerializers(reg *hsm.Registry) error { timer_queue_task_executor_base.go ×6
93 > if err := reg.RegisterTaskSerializer(
94 > TaskTypeImmediate,
95 > ImmediateTaskSerializer{},
96 > ); err != nil {
97 return err
98 }
99 > return reg.RegisterTaskSerializer(TaskTypeTimer, TimerTaskSerializer{}) timer_queue_task_executor_base.go ×6
100 }