tree.go ×6

Frontier kind: Code frontier

unlabeled · c_ea2d35cc53cb

160 tests · 1313 LOC · 57 files · introduces 0 tests · 33 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges33 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
125 ranges1313 lines · 57 files · Browse complete extent
All tests (intent)
160 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.

1 file ranked by introduced lines: 33 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/hsm/tree.go 33 introduced LOC · 6 ranges

Open complete file

583 // It updates the state machine's metadata and marks the entry as dirty in the node's cache.
584 // If the transition fails, the changes are rolled back and no state is mutated.
585 > func MachineTransition[T any](n *Node, transitionFn func(T) (TransitionOutput, error)) (retErr error) { tree.go
586 > if n.cache.deleted {
587 return fmt.Errorf("%w: cannot transition deleted node: %v", ErrStateMachineInvalidState, n.Key)
588 }
589
590 > data, err := MachineData[T](n) tree.go
591 > if err != nil {
592 return err
593 }
594 // Update the transition counts before applying the transition function in case the transition function needs to
595 // generate references to this node.
596 > n.persistence.TransitionCount++ tree.go
597 > prevLastUpdatedVersionedTransition := n.persistence.LastUpdateVersionedTransition
598 > n.persistence.LastUpdateVersionedTransition = &persistencespb.VersionedTransition{
599 > NamespaceFailoverVersion: n.backend.GetCurrentVersion(),
600 > // The transition count for the backend is only incremented when closing the current transaction,
601 > // but any change to state machine node is a state transtion,
602 > // so we can safely using next transition count here.
603 > TransitionCount: n.backend.NextTransitionCount(),
604 > }
605 > // Rollback on error
606 > defer func() {
607 > if retErr != nil {
608 n.persistence.TransitionCount--
609 n.persistence.LastUpdateVersionedTransition = prevLastUpdatedVersionedTransition
612 }
613 }()
614 > output, err := transitionFn(data) tree.go
615 > if err != nil {
616 return err
617 }
618 > serialized, err := n.definition.Serialize(data) tree.go
619 > if err != nil {
620 return err
621 }
622 > n.persistence.Data = serialized tree.go
623 > n.cache.dirty = true
624 >
625 > root := n.root()
626 > root.opLog = append(root.opLog, TransitionOperation{
627 > path: n.Path(),
628 > Output: TransitionOutputWithCount{
629 > TransitionOutput: output,
630 > TransitionCount: n.persistence.TransitionCount,
631 > },
632 > })
633 >
634 > return nil
635 }
636