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

95 LOC · 26 covered · 69 uncovered · 8 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/tasks.go · 100 LOCdummy/tasks.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_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/statemachine.go · 95 LOCdummy/statemachine.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 "encoding/json"
5
6 "go.temporal.io/api/serviceerror"
7 "go.temporal.io/server/service/history/hsm"
8 )
9
10 type State int
11
12 const (
13 State0 State = iota
14 State1
15 )
16
17 var StateMachineType = "dummy.Dummy"
18
19 > func MachineCollection(tree *hsm.Node) hsm.Collection[*Dummy] { timer_queue_task_executor_base.go ×6
20 > return hsm.NewCollection[*Dummy](tree, StateMachineType)
21 > }
22
23 // Dummy state machine.
24 // It's used for writing unit tests. Do not use in production!
25 type Dummy struct {
26 CurrentState State
27 }
28
29 var _ hsm.StateMachine[State] = &Dummy{}
30
31 // NewDummy creates a new callback in the STANDBY state from given params.
32 > func NewDummy() *Dummy { timer_queue_task_executor_base.go ×6
33 > return &Dummy{
34 > CurrentState: State0,
35 > }
36 > }
37
38 > func (sm *Dummy) State() State { statemachine.go ×3
39 > return sm.CurrentState
40 > }
41
42 > func (sm *Dummy) SetState(state State) { statemachine.go ×3
43 > sm.CurrentState = state
44 > }
45
46 func (sm Dummy) RegenerateTasks(*hsm.Node) ([]hsm.Task, error) {
47 return []hsm.Task{}, nil
48 }
49
50 type stateMachineDefinition struct{}
51
52 var _ hsm.StateMachineDefinition = stateMachineDefinition{}
53
54 > func (stateMachineDefinition) Type() string { timer_queue_task_executor_base.go ×6
55 > return StateMachineType
56 > }
57
58 func (stateMachineDefinition) Deserialize(d []byte) (any, error) {
59 sm := &Dummy{}
60 err := json.Unmarshal(d, &sm)
61 return sm, err
62 }
63
64 > func (stateMachineDefinition) Serialize(state any) ([]byte, error) { timer_queue_task_executor_base.go ×6
65 > return json.Marshal(state)
66 > }
67
68 func (stateMachineDefinition) CompareState(s1, s2 any) (int, error) {
69 // This is just a dummy used in tests, CompareState is not used.
70 return 0, serviceerror.NewUnimplemented("CompareState not implemented for dummy state machine")
71 }
72
73 > func RegisterStateMachine(r *hsm.Registry) error { timer_queue_task_executor_base.go ×6
74 > return r.RegisterMachine(stateMachineDefinition{})
75 > }
76
77 type Event0 struct{}
78
79 var Transition0 = hsm.NewTransition(
80 []State{State0, State1},
81 State0,
82 > func(sm *Dummy, e Event0) (hsm.TransitionOutput, error) { statemachine.go ×3
83 > return hsm.TransitionOutput{}, nil
84 > },
85 )
86
87 type Event1 struct{}
88
89 var Transition1 = hsm.NewTransition(
90 []State{State0, State1},
91 State1,
92 func(sm *Dummy, e Event1) (hsm.TransitionOutput, error) {
93 return hsm.TransitionOutput{}, nil
94 },
95 )