matching_task_store_v2.go ×19

Frontier kind: Code frontier

unlabeled · c_3f9634f5d2c8

2 tests · 3669 LOC · 169 files · introduces 0 tests · 74 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges74 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
638 ranges3669 lines · 169 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.

1 file ranked by introduced lines: 74 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/cassandra/matching_task_store_v2.go 74 introduced LOC · 19 ranges

Open complete file

63 ctx context.Context,
64 request *p.InternalCreateTasksRequest,
65 > ) (*p.CreateTasksResponse, error) { matching_task_store_v2.go
66 > batch := d.Session.NewBatch(gocql.LoggedBatch).WithContext(ctx)
67 > namespaceID := request.NamespaceID
68 > taskQueue := request.TaskQueue
69 > taskQueueType := request.TaskType
70 >
71 > for _, task := range request.Tasks {
72 > if task.TaskPass == 0 {
73 return nil, serviceerror.NewInternal("invalid fair queue task missing pass number")
74 }
75
76 > batch.Query(templateCreateTaskQuery_v2, matching_task_store_v2.go
77 > namespaceID,
78 > taskQueue,
79 > taskQueueType,
80 > rowTypeTaskInSubqueue(task.Subqueue),
81 > task.TaskPass,
82 > task.TaskId,
83 > task.Task.Data,
84 > task.Task.EncodingType.String())
85 }
86
88 // When UpdateMetadata is true, we also write the metadata blob (backlog counts, etc.).
89 // When false, we only check the range_id for write fencing.
90 > if request.UpdateMetadata { matching_task_store_v2.go
91 batch.Query(switchTasksTable(templateUpdateTaskQueueQuery, matchingTaskVersion2),
92 request.RangeID,
100 request.RangeID,
101 )
102 > } else { matching_task_store_v2.go
103 > batch.Query(switchTasksTable(templateCheckRangeIDQuery, matchingTaskVersion2),
104 > request.RangeID,
105 > namespaceID,
106 > taskQueue,
107 > taskQueueType,
108 > rowTypeTaskQueue,
109 > taskQueueTaskID,
110 > request.RangeID,
111 > )
112 > }
113
114 > previous := make(map[string]any) matching_task_store_v2.go
115 > applied, _, err := d.Session.MapExecuteBatchCAS(batch, previous)
116 > if err != nil {
117 return nil, gocql.ConvertError("CreateTasks", err)
118 }
119 > if !applied { matching_task_store_v2.go
120 rangeID := previous["range_id"]
121 return nil, &p.ConditionFailedError{
125 }
126
127 > return &p.CreateTasksResponse{UpdatedMetadata: request.UpdateMetadata}, nil matching_task_store_v2.go
128 }
129
132 ctx context.Context,
133 request *p.GetTasksRequest,
134 > ) (*p.InternalGetTasksResponse, error) { matching_task_store_v2.go
135 > if request.InclusiveMinPass < 1 {
136 return nil, serviceerror.NewInternal("invalid GetTasks request on fair queue: InclusiveMinPass must be >= 1")
137 }
138 > if request.ExclusiveMaxTaskID != math.MaxInt64 { matching_task_store_v2.go
139 // ExclusiveMaxTaskID is not supported in fair queue.
140 return nil, serviceerror.NewInternal("invalid GetTasks request on fair queue: ExclusiveMaxTaskID is not supported")
142
143 // Reading taskqueue tasks need to be quorum level consistent, otherwise we could lose tasks
144 > var query gocql.Query matching_task_store_v2.go
145 > rowType := rowTypeTaskInSubqueue(request.Subqueue)
146 > if request.UseLimit {
147 query = d.Session.Query(templateGetTasksQuery_v2_limit,
148 request.NamespaceID,
157 request.PageSize,
158 )
159 > } else { matching_task_store_v2.go
160 > query = d.Session.Query(templateGetTasksQuery_v2,
161 > request.NamespaceID,
162 > request.TaskQueue,
163 > request.TaskType,
164 > rowType,
165 > request.InclusiveMinPass,
166 > request.InclusiveMinTaskID,
167 > rowType,
168 > int64(math.MaxInt64),
169 > int64(math.MaxInt64),
170 > )
171 > }
172 > iter := query.WithContext(ctx).PageSize(request.PageSize).PageState(request.NextPageToken).Iter()
173 >
174 > response := &p.InternalGetTasksResponse{}
175 > task := make(map[string]any)
176 > for iter.MapScan(task) {
177 > _, ok := task["task_id"]
178 > if !ok { // no tasks, but static column record returned
179 continue
180 }
181
182 > rawTask, ok := task["task"] matching_task_store_v2.go
183 > if !ok {
184 return nil, newFieldNotFoundError("task", task)
185 }
186 > taskVal, ok := rawTask.([]byte) matching_task_store_v2.go
187 > if !ok {
188 var byteSliceType []byte
189 return nil, newPersistedTypeMismatchError("task", byteSliceType, rawTask, task)
190 }
191
192 > rawEncoding, ok := task["task_encoding"] matching_task_store_v2.go
193 > if !ok {
194 return nil, newFieldNotFoundError("task_encoding", task)
195 }
196 > encodingVal, ok := rawEncoding.(string) matching_task_store_v2.go
197 > if !ok {
198 var byteSliceType []byte
199 return nil, newPersistedTypeMismatchError("task_encoding", byteSliceType, rawEncoding, task)
200 }
201 > response.Tasks = append(response.Tasks, p.NewDataBlob(taskVal, encodingVal)) matching_task_store_v2.go
202 >
203 > task = make(map[string]any) // Reinitialize map as initialized fails on unmarshalling
204 }
205 > if len(iter.PageState()) > 0 { matching_task_store_v2.go
206 response.NextPageToken = iter.PageState()
207 }
208
209 > if err := iter.Close(); err != nil { matching_task_store_v2.go
210 return nil, gocql.ConvertError("GetTasks", err)
211 }
212 > return response, nil matching_task_store_v2.go
213 }
214