mutable_state_impl.go ×12

Frontier kind: Code frontier

unlabeled · c_4d4df420ea2a

16 tests · 8038 LOC · 247 files · introduces 0 tests · 57 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges57 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1615 ranges8038 lines · 247 files · Browse complete extent
All tests (intent)
16 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.

4 files ranked by introduced lines: 57 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/workflow/mutable_state_impl.go 38 introduced LOC · 12 ranges

Open complete file

3390 return nil
3391 }
3392 > if ms.chasmCallbacksEnabled() { mutable_state_impl.go
3393 // Initialize chasm tree once for new workflows.
3394 // Using context.Background() because this is done outside an actual request context and the
3398 }
3399
3400 > return ms.addCompletionCallbacksHsm(event, requestID, completionCallbacks) mutable_state_impl.go
3401 }
3402
3406 requestID string,
3407 completionCallbacks []*commonpb.Callback,
3408 > ) error { mutable_state_impl.go
3409 > coll := callbacks.MachineCollection(ms.HSM())
3410 > maxCallbacksPerWorkflow := ms.config.MaxCallbacksPerWorkflow(ms.GetNamespaceEntry().Name().String())
3411 > if len(completionCallbacks)+coll.Size() > maxCallbacksPerWorkflow {
3412 return serviceerror.NewFailedPreconditionf(
3413 "cannot attach more than %d callbacks to a workflow (%d callbacks already attached)",
3416 )
3417 }
3418 > for idx, cb := range completionCallbacks { mutable_state_impl.go
3419 > persistenceCB := &persistencespb.Callback{
3420 > Links: cb.GetLinks(),
3421 > }
3422 > switch variant := cb.Variant.(type) {
3423 > case *commonpb.Callback_Nexus_:
3424 > persistenceCB.Variant = &persistencespb.Callback_Nexus_{
3425 > Nexus: &persistencespb.Callback_Nexus{
3426 > Url: variant.Nexus.GetUrl(),
3427 > Header: variant.Nexus.GetHeader(),
3428 > },
3429 > }
3430 default:
3431 return serviceerror.NewInvalidArgumentf("unknown callback variant: %T", cb.Variant)
3432 }
3433 > machine := callbacks.NewCallback(requestID, event.EventTime, callbacks.NewWorkflowClosedTrigger(), persistenceCB) mutable_state_impl.go
3434 > id := ""
3435 > // This is for backwards compatibility: callbacks were initially only attached when the workflow
3436 > // execution started, but now they can be attached while the workflow is running.
3437 > if event.GetEventType() == enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED {
3438 > // Use the start event version and ID as part of the callback ID to ensure that callbacks have unique
3439 > // IDs that are deterministically created across clusters.
3440 > id = fmt.Sprintf("%d-%d-%d", event.GetVersion(), event.GetEventId(), idx)
3441 > } else {
3442 id = fmt.Sprintf("cb-%s-%d", requestID, idx)
3443 }
3444 > if _, err := coll.Add(id, machine); err != nil { mutable_state_impl.go
3445 return err
3446 }
3447 }
3448 > return nil mutable_state_impl.go
3449 }
3450
7213 coll := callbacks.MachineCollection(ms.HSM())
7214 for _, node := range coll.List() {
7215 > cb, err := coll.Data(node.Key.ID) mutable_state_impl.go
7216 > if err != nil {
7217 return err
7218 }
7219 // Only try to trigger "WorkflowClosed" callbacks.
7220 > if _, ok := cb.Trigger.Variant.(*persistencespb.CallbackInfo_Trigger_WorkflowClosed); !ok { mutable_state_impl.go
7221 continue
7222 }
7223 > err = coll.Transition(node.Key.ID, func(cb callbacks.Callback) (hsm.TransitionOutput, error) { mutable_state_impl.go
7224 > return callbacks.TransitionScheduled.Apply(cb, callbacks.EventScheduled{})
7225 > })
7226 > if err != nil {
7227 return err
7228 }
8558 // For those nodes, we need to make sure their states will be synced as well.
8559 // So when clearing buffered events, generate another SyncHSM task.
8560 > if clearBufferEvents || (ms.HSM().Dirty() && len(eventBatches) == 0) { mutable_state_impl.go
8561 return []tasks.Task{
8562 &tasks.SyncHSMTask{
8567 }
8568
8569 > return emptyTasks mutable_state_impl.go
8570 case historyi.TransactionPolicyPassive:
8571 return emptyTasks
go.temporal.io/server/service/history/outbound_queue_factory.go 13 introduced LOC · 4 ranges

Open complete file

318 }
319
320 > func StateMachineTask(smRegistry *hsm.Registry, task tasks.Task) (hsm.Ref, hsm.Task, error) { outbound_queue_factory.go
321 > cbt, ok := task.(*tasks.StateMachineOutboundTask)
322 > if !ok {
323 return hsm.Ref{}, nil, queueserrors.NewUnprocessableTaskError("unknown task type")
324 }
325 > def, ok := smRegistry.TaskSerializer(cbt.Info.Type) outbound_queue_factory.go
326 > if !ok {
327 return hsm.Ref{},
328 nil,
331 )
332 }
333 > smt, err := def.Deserialize(cbt.Info.Data, hsm.TaskAttributes{Destination: cbt.Destination}) outbound_queue_factory.go
334 > if err != nil {
335 return hsm.Ref{},
336 nil,
341 )
342 }
343 > return hsm.Ref{ outbound_queue_factory.go
344 > WorkflowKey: taskWorkflowKey(task),
345 > StateMachineRef: cbt.Info.Ref,
346 > TaskID: task.GetTaskID(),
347 > Validate: smt.Validate,
348 > }, smt, nil
349 }
350
go.temporal.io/server/components/callbacks/tasks.go 3 introduced LOC · 1 range

Open complete file

44 type InvocationTaskSerializer struct{}
45
46 > func (InvocationTaskSerializer) Deserialize(data []byte, attrs hsm.TaskAttributes) (hsm.Task, error) { tasks.go
47 > return InvocationTask{destination: attrs.Destination}, nil
48 > }
49
50 func (InvocationTaskSerializer) Serialize(hsm.Task) ([]byte, error) {
go.temporal.io/server/service/history/tasks/state_machine_task.go 3 introduced LOC · 1 range

Open complete file

19 var _ HasOutboundTaskGroup = &StateMachineTask{}
20
21 > func (t *StateMachineTask) GetTaskID() int64 { state_machine_task.go
22 > return t.TaskID
23 > }
24
25 func (t *StateMachineTask) SetTaskID(id int64) {