mutable_state_impl.go ×9

Frontier kind: Code frontier

unlabeled · c_900f72aef858

2 tests · 8847 LOC · 263 files · introduces 0 tests · 46 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges46 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1975 ranges8847 lines · 263 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.

3 files ranked by introduced lines: 46 introduced LOC across 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/workflow/mutable_state_impl.go 25 introduced LOC · 9 ranges

Open complete file

707 // Returns the workflow component (which is *chasmworkflow.Workflow) and the CHASM mutable context.
708 // This method is for write operations. Callers can type assert to *chasmworkflow.Workflow if needed.
709 > func (ms *MutableStateImpl) ChasmWorkflowComponent(ctx context.Context) (*chasmworkflow.Workflow, chasm.MutableContext, error) { mutable_state_impl.go
710 > chasmCtx := chasm.NewMutableContext(ctx, ms.chasmTree.(*chasm.Node))
711 > rootComponent, err := ms.chasmTree.ComponentByPath(chasmCtx, nil)
712 > if err != nil {
713 return nil, nil, err
714 }
715 > wf, ok := rootComponent.(*chasmworkflow.Workflow) mutable_state_impl.go
716 > if !ok {
717 return nil, nil, serviceerror.NewInternalf("expected workflow component, but got %T", rootComponent)
718 }
719 > return wf, chasmCtx, nil mutable_state_impl.go
720 }
721
722 > func (ms *MutableStateImpl) EnsureChasmWorkflowComponent(ctx context.Context) { mutable_state_impl.go
723 > // Initialize chasm tree once for new workflows.
724 > // Using context.Background() because this is done outside an actual request context and the
725 > // chasmworkflow.NewWorkflow does not actually use it currently.
726 > root, ok := ms.chasmTree.(*chasm.Node)
727 > softassert.That(ms.logger, ok, "chasmTree cast failed")
728 >
729 > if root.ArchetypeID() == chasm.UnspecifiedArchetypeID {
730 mutableContext := chasm.NewMutableContext(ctx, root)
731 if err := root.SetRootComponent(chasmworkflow.NewWorkflow(mutableContext, chasm.NewMSPointer(ms))); err != nil {
2510 signalExists := false
2511 if ms.ChasmSignalBacklinksEnabled() {
2512 > wf, chasmCtx, err := ms.ChasmWorkflowComponentReadOnly(context.Background()) mutable_state_impl.go
2513 > if err != nil {
2514 softassert.Fail(ms.logger, fmt.Sprintf("Unexpected error reading CHASM component: %v", err))
2515 }
2516 > signalExists = wf.HasIncomingSignalEvent(chasmCtx, requestID) mutable_state_impl.go
2517 }
2518
6170 requestID := signalEventAttrs.WorkflowExecutionSignaledEventAttributes.GetRequestId()
6171 if requestID != "" && ms.ChasmSignalBacklinksEnabled() {
6172 > ctx := context.Background() mutable_state_impl.go
6173 > ms.EnsureChasmWorkflowComponent(ctx)
6174 > wf, chasmCtx, err := ms.ChasmWorkflowComponent(ctx)
6175 > if err != nil {
6176 return err
6177 }
6179 // - For buffered events (normal processing path), event.GetEventId() returns the common.BufferedEventID and will be resolved later.
6180 // - For already-persisted events (rebuild/replay path), event.GetEventId() returns the real history event ID.
6181 > nsTag := metrics.NamespaceTag(ms.GetNamespaceEntry().Name().String()) mutable_state_impl.go
6182 > if err := wf.AddIncomingSignalEvent(chasmCtx, requestID, event.GetEventId()); err != nil {
6183 return err
6184 }
6185 > metrics.ChasmIncomingSignalWritten.With(ms.metricsHandler.WithTags(nsTag)).Record(1) mutable_state_impl.go
6186 }
6187 return nil
go.temporal.io/server/chasm/lib/workflow/workflow.go 13 introduced LOC · 4 ranges

Open complete file

273 requestID string,
274 eventID int64,
275 > ) error { workflow.go
276 > if w.IncomingSignals == nil {
277 w.IncomingSignals = make(chasm.Map[string, *chasmworkflowpb.IncomingSignalData])
278 }
279 > if w.HasIncomingSignalEvent(ctx, requestID) { workflow.go
280 return nil
281 }
282 > w.IncomingSignals[requestID] = chasm.NewDataField(ctx, &chasmworkflowpb.IncomingSignalData{ workflow.go
283 > // This might be common.BufferedEventID, which will be updated via UpdateIncomingSignalEvent
284 > // once this signal is flushed to DB.
285 > EventId: eventID,
286 > })
287 > return nil
288 }
289
305 // HasIncomingSignalEvent returns true if a signal with this requestID is already persisted
306 // in this CHASM tree.
307 > func (w *Workflow) HasIncomingSignalEvent(_ chasm.Context, requestID string) bool { workflow.go
308 > _, exists := w.IncomingSignals[requestID]
309 > return exists
310 > }
311
312 // HasAnyBufferedEvent returns true if the workflow has any buffered event matching the given filter.
go.temporal.io/server/chasm/lib/workflow/gen/workflowpb/v1/state.pb.go 8 introduced LOC · 1 range

Open complete file

148 func (*IncomingSignalData) ProtoMessage() {}
149
150 > func (x *IncomingSignalData) ProtoReflect() protoreflect.Message { state.pb.go
151 > mi := &file_temporal_server_chasm_lib_workflow_proto_v1_state_proto_msgTypes[2]
152 > if x != nil {
153 > ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
154 > if ms.LoadMessageInfo() == nil {
155 > ms.StoreMessageInfo(mi)
156 > }
157 > return ms
158 }
159 return mi.MessageOf(x)