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.
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.
package dummy
import (
"encoding/json"
"go.temporal.io/api/serviceerror"
"go.temporal.io/server/service/history/hsm"
)
type State int
const (
State0 State = iota
State1
)
var StateMachineType = "dummy.Dummy"
func MachineCollection(tree *hsm.Node) hsm.Collection[*Dummy] {
timer_queue_task_executor_base.go ×6
return hsm.NewCollection[*Dummy](tree, StateMachineType)
}
// Dummy state machine.
// It's used for writing unit tests. Do not use in production!
type Dummy struct {
CurrentState State
}
var _ hsm.StateMachine[State] = &Dummy{}
// NewDummy creates a new callback in the STANDBY state from given params.
return &Dummy{
CurrentState: State0,
}
}
return sm.CurrentState
}
sm.CurrentState = state
}
func (sm Dummy) RegenerateTasks(*hsm.Node) ([]hsm.Task, error) {
return []hsm.Task{}, nil
}
type stateMachineDefinition struct{}
var _ hsm.StateMachineDefinition = stateMachineDefinition{}
return StateMachineType
}
func (stateMachineDefinition) Deserialize(d []byte) (any, error) {
sm := &Dummy{}
err := json.Unmarshal(d, &sm)
return sm, err
}
func (stateMachineDefinition) Serialize(state any) ([]byte, error) {
timer_queue_task_executor_base.go ×6
return json.Marshal(state)
}
func (stateMachineDefinition) CompareState(s1, s2 any) (int, error) {
// This is just a dummy used in tests, CompareState is not used.
return 0, serviceerror.NewUnimplemented("CompareState not implemented for dummy state machine")
}
return r.RegisterMachine(stateMachineDefinition{})
}
type Event0 struct{}
var Transition0 = hsm.NewTransition(
[]State{State0, State1},
State0,
return hsm.TransitionOutput{}, nil
},
)
type Event1 struct{}
var Transition1 = hsm.NewTransition(
[]State{State0, State1},
State1,
func(sm *Dummy, e Event1) (hsm.TransitionOutput, error) {
return hsm.TransitionOutput{}, nil
},
)