chasm_decoder.go ×13

Frontier kind: Code frontier

unlabeled · c_63927a210e1e

2 tests · 3331 LOC · 149 files · introduces 0 tests · 72 LOC · 6 files

Introduces — evidence that enters the hierarchy at this concept

Code
24 ranges72 lines · 6 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
567 ranges3331 lines · 149 files · Browse complete extent
All tests (intent)
2 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.

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

go.temporal.io/server/tools/tdbg/chasm_decoder.go 48 introduced LOC · 13 ranges

Open complete file

36 }
37
38 > func getNodeType(metadata *persistencespb.ChasmNodeMetadata) string { chasm_decoder.go
39 > switch {
40 > case metadata.GetComponentAttributes() != nil:
41 > return "component"
42 case metadata.GetCollectionAttributes() != nil:
43 return "collection"
110 }
111
112 > func decodeNode(node *persistencespb.ChasmNode, registry *chasm.Registry) (*decodedChasmNode, error) { chasm_decoder.go
113 > metadata := node.GetMetadata()
114 > componentAttr := metadata.GetComponentAttributes()
115 >
116 > if componentAttr == nil {
117 return &decodedChasmNode{
118 Metadata: metadata,
122 }
123
124 > typeID := componentAttr.GetTypeId() chasm_decoder.go
125 > rc, ok := registry.ComponentByID(typeID)
126 > if !ok {
127 return &decodedChasmNode{
128 Metadata: metadata,
132 }
133
134 > result := &decodedChasmNode{ chasm_decoder.go
135 > Metadata: metadata,
136 > NodeType: getNodeType(metadata),
137 > }
138 >
139 > goType := rc.GoType()
140 > if goType == nil {
141 return nil, errors.New("component has no Go type")
142 }
143
144 > messageValue := reflect.New(goType.Elem()) chasm_decoder.go
145 > message, ok := messageValue.Interface().(proto.Message)
146 > if !ok {
147 result.RawData = node.GetData()
148 result.NodeType = "component (stateless)"
149 > } else { chasm_decoder.go
150 > dataBlob := node.GetData()
151 > if dataBlob != nil && len(dataBlob.GetData()) > 0 {
152 > message = message.ProtoReflect().New().Interface()
153 > if err := serialization.Decode(dataBlob, message); err != nil {
154 result.RawData = dataBlob
155 result.NodeType = "component (decode error)"
156 > } else { chasm_decoder.go
157 > jsonBytes, err := codec.NewJSONPBEncoder().Encode(message)
158 > if err != nil {
159 return nil, fmt.Errorf("failed to encode to JSON: %w", err)
160 }
161 > result.DecodedData = json.RawMessage(jsonBytes) chasm_decoder.go
162 > result.NodeType = "component"
163 }
164 }
165 }
166
167 > fqn, _ := registry.ComponentFqnByID(typeID) chasm_decoder.go
168 > result.ComponentFQN = fqn
169 >
170 > sideEffectTasks, err := decodeTasks(componentAttr.GetSideEffectTasks(), registry)
171 > if err != nil {
172 return nil, fmt.Errorf("failed to decode side effect task: %w", err)
173 }
174 > result.SideEffectTasks = sideEffectTasks chasm_decoder.go
175 >
176 > pureTasks, err := decodeTasks(componentAttr.GetPureTasks(), registry)
177 > if err != nil {
178 return nil, fmt.Errorf("failed to decode pure task: %w", err)
179 }
180 > result.PureTasks = pureTasks chasm_decoder.go
181 >
182 > return result, nil
183 }
184
186 tasks []*persistencespb.ChasmComponentAttributes_Task,
187 registry *chasm.Registry,
188 > ) ([]*decodedTask, error) { chasm_decoder.go
189 > result := make([]*decodedTask, len(tasks))
190 > for i, task := range tasks {
191 decodedTask, err := decodeTask(task, registry)
192 if err != nil {
195 result[i] = decodedTask
196 }
197 > return result, nil chasm_decoder.go
198 }
199
go.temporal.io/server/tools/tdbg/chasm_registry.go 10 introduced LOC · 7 ranges

Open complete file

11 )
12
13 > func newChasmRegistry(logger log.Logger) (*chasm.Registry, error) { chasm_registry.go
14 > registry := chasm.NewRegistry(logger)
15 >
16 > if err := registry.Register(&chasm.CoreLibrary{}); err != nil {
17 return nil, err
18 }
19
20 > if err := registry.Register(chasmworkflow.NewLibrary(chasmworkflow.NewRegistry())); err != nil { chasm_registry.go
21 return nil, err
22 }
23
24 > if err := registry.Register(activitylib.NewNilLibrary()); err != nil { chasm_registry.go
25 return nil, err
26 }
27
28 > if err := registry.Register(chasmscheduler.NewNilLibrary()); err != nil { chasm_registry.go
29 return nil, err
30 }
31
32 > if err := registry.Register(chasmtests.Library); err != nil { chasm_registry.go
33 return nil, err
34 }
35
36 > if err := registry.Register(callbacklib.NewNilLibrary()); err != nil { chasm_registry.go
37 return nil, err
38 }
39
40 > return registry, nil chasm_registry.go
41 }
go.temporal.io/server/chasm/lib/activity/library.go 5 introduced LOC · 1 range

Open complete file

78 // NewNilLibrary creates a Library with all nil handlers. Useful for
79 // registration-only contexts like tdbg where no task execution is needed.
80 > func NewNilLibrary() chasm.Library { library.go
81 > return &library{
82 > componentOnlyLibrary: *newComponentOnlyLibrary(nil, nil),
83 > }
84 > }
85
86 type library struct {
go.temporal.io/server/chasm/lib/callback/library.go 3 introduced LOC · 1 range

Open complete file

17 // NewNilLibrary creates a Library with all nil handlers. Useful for
18 // registration-only contexts like tdbg where no task execution is needed.
19 > func NewNilLibrary() *Library { library.go
20 > return &Library{}
21 > }
22
23 func newLibrary(
go.temporal.io/server/chasm/lib/scheduler/library.go 3 introduced LOC · 1 range

Open complete file

26 // NewNilLibrary creates a Library with all nil handlers. Useful for
27 // registration-only contexts like tdbg where no task execution is needed.
28 > func NewNilLibrary() *Library { library.go
29 > return &Library{}
30 > }
31
32 func NewLibrary(
go.temporal.io/server/chasm/registrable_component.go 3 introduced LOC · 1 range

Open complete file

218
219 // GoType returns the reflect.Type of the component's Go struct.
220 > func (rc *RegistrableComponent) GoType() reflect.Type { registrable_component.go
221 > return rc.goType
222 > }
223
224 // fqType returns the fully qualified name of the component, which is a combination of