tree.go ×5

Frontier kind: Code frontier

unlabeled · c_9b4f4cdf3877

158 tests · 1308 LOC · 57 files · introduces 0 tests · 39 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges39 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
120 ranges1308 lines · 57 files · Browse complete extent
All tests (intent)
158 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: 39 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/hsm/tree.go 39 introduced LOC · 5 ranges

Open complete file

349 // Returns [ErrStateMachineAlreadyExists] if a child with the given key already exists, [ErrNotRegistered] if the key's
350 // type is not found in the node's state machine registry and serialization errors.
351 > func (n *Node) AddChild(key Key, data any) (*Node, error) { tree.go
352 > machines, ok := n.persistence.Children[key.Type]
353 > if ok {
354 if _, ok = machines.MachinesById[key.ID]; ok {
355 if ok {
358 }
359 }
360 > def, ok := n.registry.Machine(key.Type) tree.go
361 > if !ok {
362 return nil, fmt.Errorf("%w: state machine for type: %v", ErrNotRegistered, key.Type)
363 }
364 > serialized, err := def.Serialize(data) tree.go
365 > if err != nil {
366 return nil, err
367 }
368
369 > nextVersionedTransition := &persistencespb.VersionedTransition{ tree.go
370 > NamespaceFailoverVersion: n.backend.GetCurrentVersion(),
371 > // The transition count for the backend is only incremented when closing the current transaction,
372 > // but any change to state machine node is a state transtion,
373 > // so we can safely using next transition count here is safe.
374 > TransitionCount: n.backend.NextTransitionCount(),
375 > }
376 > node := &Node{
377 > Key: key,
378 > Parent: n,
379 > definition: def,
380 > registry: n.registry,
381 > persistence: &persistencespb.StateMachineNode{
382 > Children: make(map[string]*persistencespb.StateMachineMap),
383 > Data: serialized,
384 > InitialVersionedTransition: nextVersionedTransition,
385 > LastUpdateVersionedTransition: nextVersionedTransition,
386 > TransitionCount: 0,
387 > },
388 > cache: &cachedMachine{
389 > dataLoaded: true,
390 > data: data,
391 > dirty: true,
392 > children: make(map[Key]*Node),
393 > },
394 > backend: n.backend,
395 > }
396 > n.cache.children[key] = node
397 > children, ok := n.persistence.Children[key.Type]
398 > if !ok {
399 children = &persistencespb.StateMachineMap{MachinesById: make(map[string]*persistencespb.StateMachineNode)}
400 // Children may be nil if the map was empty and the proto message we serialized and deserialized.
404 n.persistence.Children[key.Type] = children
405 }
406 > children.MachinesById[key.ID] = node.persistence tree.go
407 > return node, nil
408 }
409