pri_task_writer.go ×10

Frontier kind: Code frontier

unlabeled · c_349047cddad6

89 tests · 3420 LOC · 149 files · introduces 0 tests · 58 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges58 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
545 ranges3420 lines · 149 files · Browse complete extent
All tests (intent)
89 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: 58 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/matching/pri_task_writer.go 43 introduced LOC · 10 ranges

Open complete file

69 subqueue subqueueIndex,
70 taskInfo *persistencespb.TaskInfo,
71 > ) error { pri_task_writer.go
72 > select {
73 case <-w.backlogMgr.tqCtx.Done():
74 return errShutdown
75 > default: pri_task_writer.go
76 // noop
77 }
78
79 > startTime := time.Now().UTC() pri_task_writer.go
80 > ch := make(chan error, 1)
81 > req := &writeTaskRequest{
82 > taskInfo: taskInfo,
83 > responseCh: ch,
84 > subqueue: subqueue,
85 > }
86 >
87 > select {
88 > case w.appendCh <- req:
89 > select {
90 > case err := <-ch:
91 > metrics.TaskWriteLatencyPerTaskQueue.With(w.backlogMgr.metricsHandler).Record(time.Since(startTime))
92 > return err
93 case <-w.backlogMgr.tqCtx.Done():
94 // if we are shutting down, this request will never make
106 }
107
108 > func (w *priTaskWriter) assignTaskIDs(reqs []*writeTaskRequest) error { pri_task_writer.go
109 > for i := range reqs {
110 > if w.taskIDBlock.start > w.taskIDBlock.end {
111 // we ran out of current allocation block
112 newBlock, err := w.allocTaskIDBlock(w.taskIDBlock.end)
116 w.taskIDBlock = newBlock
117 }
118 > reqs[i].id = w.taskIDBlock.start pri_task_writer.go
119 > w.taskIDBlock.start++
120 }
121 > return nil pri_task_writer.go
122 }
123
124 > func (w *priTaskWriter) appendTasks(reqs []*writeTaskRequest) error { pri_task_writer.go
125 > resp, err := w.db.CreateTasks(w.backlogMgr.tqCtx, reqs)
126 > if err != nil {
127 w.backlogMgr.signalIfFatal(err)
128 w.logger.Error("Persistent store operation failure",
161
162 select {
163 > case request := <-w.appendCh: pri_task_writer.go
164 > // read a batch of requests from the channel
165 > reqs = append(reqs[:0], request)
166 > reqs = w.getWriteBatch(reqs)
167 >
168 > err := w.assignTaskIDs(reqs)
169 > if err == nil {
170 > err = w.appendTasks(reqs)
171 > }
172 > for _, req := range reqs {
173 > req.responseCh <- err
174 > }
175
176 case <-w.backlogMgr.tqCtx.Done():
180 }
181
182 > func (w *priTaskWriter) getWriteBatch(reqs []*writeTaskRequest) []*writeTaskRequest { pri_task_writer.go
183 > for range w.config.MaxTaskBatchSize() - 1 {
184 > select {
185 case req := <-w.appendCh:
186 reqs = append(reqs, req)
187 > default: // channel is empty, don't block pri_task_writer.go
188 > return reqs
189 }
190 }
go.temporal.io/server/service/matching/pri_backlog_manager.go 15 introduced LOC · 2 ranges

Open complete file

193 }
194
195 > func (c *priBacklogManagerImpl) getSubqueueForPriority(priority priorityKey) subqueueIndex { pri_backlog_manager.go
196 > priority = c.config.clipPriority(priority)
197 >
198 > c.subqueueLock.Lock()
199 > defer c.subqueueLock.Unlock()
200 >
201 > if i, ok := c.subqueuesByPriority[priority]; ok {
202 > return i
203 > }
204
205 // We need to allocate a new subqueue. Note this is doing io under subqueueLock,
247 }
248
249 > func (c *priBacklogManagerImpl) SpoolTask(taskInfo *persistencespb.TaskInfo) error { pri_backlog_manager.go
250 > subqueue := c.getSubqueueForPriority(priorityKey(taskInfo.Priority.GetPriorityKey()))
251 > err := c.taskWriter.appendTask(subqueue, taskInfo)
252 > c.signalIfFatal(err)
253 > return err
254 > }
255
256 func (c *priBacklogManagerImpl) signalReaders(resp createTasksResponse) {