matching_task_store_v1.go ×12

Frontier kind: Code frontier

unlabeled · c_aba3afc1c59a

4 tests · 3629 LOC · 169 files · introduces 0 tests · 62 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges62 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
622 ranges3629 lines · 169 files · Browse complete extent
All tests (intent)
4 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.

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

go.temporal.io/server/common/persistence/cassandra/matching_task_store_v1.go 56 introduced LOC · 12 ranges

Open complete file

56 ctx context.Context,
57 request *p.InternalCreateTasksRequest,
58 > ) (*p.CreateTasksResponse, error) { matching_task_store_v1.go
59 > batch := d.Session.NewBatch(gocql.LoggedBatch).WithContext(ctx)
60 > namespaceID := request.NamespaceID
61 > taskQueue := request.TaskQueue
62 > taskQueueType := request.TaskType
63 >
64 > for _, task := range request.Tasks {
65 > if task.TaskPass != 0 {
66 return nil, serviceerror.NewInternal("invalid non-fair queue task with pass number")
67 }
68
69 > ttl := getTaskTTL(task.ExpiryTime) matching_task_store_v1.go
70 >
71 > if ttl <= 0 || ttl > maxCassandraTTL {
72 batch.Query(templateCreateTaskQuery,
73 namespaceID,
78 task.Task.Data,
79 task.Task.EncodingType.String())
81 > batch.Query(templateCreateTaskWithTTLQuery,
82 > namespaceID,
83 > taskQueue,
84 > taskQueueType,
85 > rowTypeTaskInSubqueue(task.Subqueue),
86 > task.TaskId,
87 > task.Task.Data,
88 > task.Task.EncodingType.String(),
89 > ttl)
90 > }
91 }
92
94 // When UpdateMetadata is true, we also write the metadata blob (backlog counts, etc.).
95 // When false, we only check the range_id for write fencing.
96 > if request.UpdateMetadata { matching_task_store_v1.go
97 batch.Query(switchTasksTable(templateUpdateTaskQueueQuery, matchingTaskVersion1),
98 request.RangeID,
106 request.RangeID,
107 )
108 > } else { matching_task_store_v1.go
109 > batch.Query(switchTasksTable(templateCheckRangeIDQuery, matchingTaskVersion1),
110 > request.RangeID,
111 > namespaceID,
112 > taskQueue,
113 > taskQueueType,
114 > rowTypeTaskQueue,
115 > taskQueueTaskID,
116 > request.RangeID,
117 > )
118 > }
119
120 > previous := make(map[string]any) matching_task_store_v1.go
121 > applied, _, err := d.Session.MapExecuteBatchCAS(batch, previous)
122 > if err != nil {
123 return nil, gocql.ConvertError("CreateTasks", err)
124 }
125 > if !applied { matching_task_store_v1.go
126 rangeID := previous["range_id"]
127 return nil, &p.ConditionFailedError{
138 ctx context.Context,
139 request *p.GetTasksRequest,
140 > ) (*p.InternalGetTasksResponse, error) { matching_task_store_v1.go
141 > if request.InclusiveMinPass != 0 {
142 return nil, serviceerror.NewInternal("invalid GetTasks request on queue: InclusiveMinPass is not supported")
143 }
144
145 // Reading taskqueue tasks need to be quorum level consistent, otherwise we could lose tasks
146 > query := d.Session.Query(templateGetTasksQuery, matching_task_store_v1.go
147 > request.NamespaceID,
148 > request.TaskQueue,
149 > request.TaskType,
150 > rowTypeTaskInSubqueue(request.Subqueue),
151 > request.InclusiveMinTaskID,
152 > request.ExclusiveMaxTaskID,
153 > ).WithContext(ctx)
154 > iter := query.PageSize(request.PageSize).PageState(request.NextPageToken).Iter()
155 >
156 > response := &p.InternalGetTasksResponse{}
157 > task := make(map[string]any)
158 > for iter.MapScan(task) {
159 _, ok := task["task_id"]
160 if !ok { // no tasks, but static column record returned
185 task = make(map[string]any) // Reinitialize map as initialized fails on unmarshalling
186 }
187 > if len(iter.PageState()) > 0 { matching_task_store_v1.go
188 response.NextPageToken = iter.PageState()
189 }
190
191 > if err := iter.Close(); err != nil { matching_task_store_v1.go
192 return nil, gocql.ConvertError("GetTasks", err)
193 }
194 > return response, nil matching_task_store_v1.go
195 }
196
go.temporal.io/server/common/persistence/cassandra/matching_task_store.go 6 introduced LOC · 2 ranges

Open complete file

39 }
40
41 > func getTaskTTL(expireTime *timestamppb.Timestamp) int64 { matching_task_store.go
42 > if expireTime == nil || expireTime.AsTime().IsZero() {
43 return 0
44 }
46 // 0 means no ttl, we dont want that.
47 // Todo: Come back and correctly ignore expired in-memory tasks before persisting
48 > expiryTTL := max( matching_task_store.go
49 > convert.Int64Ceil(time.Until(expireTime.AsTime()).Seconds()), 1)
50 >
51 > return expiryTTL
52 }