activities.go ×15

Frontier kind: Code frontier

unlabeled · c_f8d4d854afe9

5 tests · 2343 LOC · 115 files · introduces 0 tests · 51 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges51 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
364 ranges2343 lines · 115 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: 51 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/batcher/activities.go 51 introduced LOC · 15 ranges

Open complete file

96
97 // hasNext returns true if there are more pages to fetch
98 > func (p *page) hasNext() bool { activities.go
99 > return len(p.nextPageToken) > 0
100 > }
101
102 // length returns the number of executions in this page. For activity batch
117
118 // nextTask returns the next task to be submitted from this page
119 > func (p *page) nextTask() task { activities.go
120 > if p.submittedCount >= p.length() {
121 return task{} // No more tasks in this page
122 }
123
124 > t := task{ activities.go
125 > attempts: 1,
126 > page: p,
127 > }
128 > if len(p.targetExecutionInfo) > 0 {
129 t.targetExecution = p.targetExecutionInfo[p.submittedCount]
130 > } else { activities.go
131 t.executionInfo = p.executionInfos[p.submittedCount]
132 }
133 > return t activities.go
134 }
135
239 logger log.Logger,
240 hbd HeartBeatDetails,
241 > ) (HeartBeatDetails, error) { activities.go
242 >
243 > concurrency := int(math.Max(1, float64(config.concurrency)))
244 >
245 > taskCh := make(chan task, concurrency)
246 > respCh := make(chan taskResponse, concurrency)
247 >
248 > // Ticker for frequent heartbeats to avoid timeout during slow processing, 1/4 of the default heartbeat timeout (10s)
249 > heartbeatTicker := time.NewTicker(defaultActivityHeartBeatTimeout / 4)
250 > defer heartbeatTicker.Stop()
251 >
252 > for range concurrency {
253 > go startWorkerProcessor(ctx, taskCh, respCh, rateLimiter, sdkClient, a.FrontendClient, metricsHandler, logger)
254 > }
255
256 // Initialize the first p from initial executions or fetch from query
257 > var p *page activities.go
258 > if len(config.initialTargetExecutions) > 0 {
259 if isActivityBatchType(config.batchType) {
260 p = &page{
320 }
321
322 > for { activities.go
323 > // Check if we need to fetch next page
324 > if p.hasNext() && p.allSubmitted() {
325 nextPage, err := fetchPage(ctx, sdkClient, config, p.nextPageToken, p.pageNumber+1)
326 if err != nil {
335 // Disable this send case (nil channel) once the page is fully submitted, so the loop
336 // waits on results instead of offering empty tasks.
337 > var submitCh chan task activities.go
338 > var nextTask task
339 > if p.submittedCount < p.length() {
340 > submitCh = taskCh
341 > nextTask = p.nextTask()
342 > }
343
344 > select { activities.go
345 > case submitCh <- nextTask:
346 > p.submittedCount++
347
348 > case result := <-respCh: activities.go
349 > resultPage := result.page
350 > if result.err == nil {
351 > resultPage.successCount++
352 > } else {
353 resultPage.errorCount++
354 }
355
356 > recordCompletedPages(&hbd, resultPage) activities.go
357
358 case <-heartbeatTicker.C:
367
368 // Check if we're done
369 > if p.done() && !p.hasNext() { activities.go
370 > break
371 }
372 }
373
374 > return hbd, nil activities.go
375 }
376
990 // activity executions (listed via ListActivityExecutions) rather than workflow
991 // executions.
992 > func isActivityBatchType(batchType enumspb.BatchOperationType) bool { activities.go
993 > switch batchType {
994 case enumspb.BATCH_OPERATION_TYPE_TERMINATE_ACTIVITY,
995 enumspb.BATCH_OPERATION_TYPE_CANCEL_ACTIVITY,