api.go ×5

Frontier kind: Code frontier

unlabeled · c_de5c62c26dd4

5 tests · 8366 LOC · 252 files · introduces 0 tests · 23 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges23 lines · 1 files
Tests
0 tests

Contains — complete concept membership

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

go.temporal.io/server/service/history/api/queryworkflow/api.go 23 introduced LOC · 5 ranges

Open complete file

103 }
104 // If workflow is paused, return query rejected with PAUSED status.
105 > if mutableStateStatus == enumspb.WORKFLOW_EXECUTION_STATUS_PAUSED { api.go
106 return &historyservice.QueryWorkflowResponse{
107 Response: &workflowservice.QueryWorkflowResponse{
113 }
114
115 > mutableState := workflowLease.GetMutableState() api.go
116 > if !mutableState.IsWorkflowExecutionRunning() && !mutableState.HasCompletedAnyWorkflowTask() {
117 // Workflow was closed before WorkflowTaskStarted event. In this case query will fail.
118 return nil, consts.ErrWorkflowClosedBeforeWorkflowTaskStarted
119 }
120
121 > if !mutableState.HadOrHasWorkflowTask() { api.go
122 // Workflow has no workflow task scheduled.
123 // This can be due to firstWorkflowTaskBackoff (cron / retry)
132 }
133
134 > if mutableState.GetExecutionInfo().WorkflowTaskAttempt >= failQueryWorkflowTaskAttemptCount { api.go
135 // while workflow task is failing, the query to that workflow will also fail. Failing fast here to prevent wasting
136 // resources to load history for a query that will fail.
143 }
144
145 > priority := mutableState.GetExecutionInfo().Priority api.go
146 >
147 > // There are two ways in which queries get dispatched to workflow worker. First, queries can be dispatched on workflow tasks.
148 > // These workflow tasks potentially contain new events and queries. The events are treated as coming before the query in time.
149 > // The second way in which queries are dispatched to workflow worker is directly through matching; in this approach queries can be
150 > // dispatched to workflow worker immediately even if there are outstanding events that came before the query. The following logic
151 > // is used to determine if a query can be safely dispatched directly through matching or must be dispatched on a workflow task.
152 > //
153 > // Precondition to dispatch query directly to matching is workflow has at least one WorkflowTaskStarted event. Otherwise, sdk would panic.
154 > if mutableState.HasCompletedAnyWorkflowTask() {
155 > // There are three cases in which a query can be dispatched directly through matching safely, without violating strong consistency level:
156 > // 1. the namespace is not active, in this case history is immutable so a query dispatched at any time is consistent
157 > // 2. the workflow is not running, whenever a workflow is not running dispatching query directly is consistent
158 > // 3. if there is no pending or started workflow tasks it means no events came before query arrived, so its safe to dispatch directly
159 > safeToDispatchDirectly := nsEntry.ActiveClusterName(namespace.RoutingKey{ID: workflowKey.WorkflowID}) != shardContext.GetClusterMetadata().GetCurrentClusterName() ||
160 > !mutableState.IsWorkflowExecutionRunning() ||
161 > (!mutableState.HasPendingWorkflowTask() && !mutableState.HasStartedWorkflowTask())
162 > if safeToDispatchDirectly {
163 msResp, err := api.MutableStateToGetResponse(mutableState)
164 if err != nil {