memory_scheduled_queue.go ×9

Frontier kind: Joint frontier

unlabeled · c_b91d2c01ae92

3 tests · 2984 LOC · 142 files · introduces 1 test · 52 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges52 lines · 3 files
Tests
1 test

Contains — complete concept membership

All code (extent)
501 ranges2984 lines · 142 files · Browse complete extent
All tests (intent)
3 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.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 52 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/queues/memory_scheduled_queue.go 39 introduced LOC · 9 ranges

Open complete file

68 this Executable,
69 that Executable,
71 > return this.GetVisibilityTime().Before(that.GetVisibilityTime())
72 > }
73
74 func (q *memoryScheduledQueue) Start() {
99 }
100
101 > func (q *memoryScheduledQueue) Add(task Executable) { memory_scheduled_queue.go
102 > q.newTaskCh <- task
103 > }
104
105 //nolint:revive // cognitive complexity
117 case <-q.shutdownCh:
118 return
119 > case newTask := <-q.newTaskCh: memory_scheduled_queue.go
120 > var nextTaskTime time.Time
121 > if !q.taskQueue.IsEmpty() {
122 > nextTaskTime = q.taskQueue.Peek().GetVisibilityTime()
123 > }
124 > q.taskQueue.Add(newTask)
125 > // If there is no timer set OR new time is earlier than the current one, then timer needs to be set to the new time.
126 > if nextTaskTime.IsZero() || newTask.GetVisibilityTime().Before(nextTaskTime) {
127 > // But before reset if timer is there it needs to be stopped.
128 > if !nextTaskTime.IsZero() {
129 > if !q.nextTaskTimer.Stop() {
130 // Drain timer channel to prevent timer firing.
131 <-q.nextTaskTimer.C
132 }
133 }
134 > q.nextTaskTimer.Reset(newTask.GetVisibilityTime().Sub(q.timeSource.Now())) memory_scheduled_queue.go
135 }
136 > metrics.NewTimerNotifyCounter.With(q.metricsHandler).Record(1) memory_scheduled_queue.go
137 > case <-q.nextTaskTimer.C:
138 > taskToExecute := q.taskQueue.Remove()
139 > // Skip tasks which are already canceled. Majority of the tasks in the queue should be cancelled already.
140 > nextTask := q.purgeCanceledTasks()
141 > if nextTask != nil {
142 > q.nextTaskTimer.Reset(nextTask.GetVisibilityTime().Sub(q.timeSource.Now()))
143 > }
144 // If current taskToExecute is also cancelled don't submit it to scheduler.
145 > if taskToExecute.State() == ctasks.TaskStateCancelled { memory_scheduled_queue.go
146 continue
147 }
148
149 // For scheduler metrics to work properly.
150 > taskToExecute.SetScheduledTime(q.timeSource.Now()) memory_scheduled_queue.go
151 >
152 > if !q.scheduler.TrySubmit(taskToExecute) {
153 // If all workers are busy then put the task back to the queue.
154 // Must be done in a separate goroutine to avoid deadlock.
161 }
162 }
163 > func (q *memoryScheduledQueue) purgeCanceledTasks() (nextTask Executable) { memory_scheduled_queue.go
164 > if !q.taskQueue.IsEmpty() {
165 > nextTask = q.taskQueue.Peek()
166 > }
167 > for nextTask != nil {
168 > if nextTask.State() != ctasks.TaskStateCancelled {
169 > return
170 > }
171 // Remove canceled task from queue.
172 q.taskQueue.Remove()
go.temporal.io/server/service/history/queues/speculative_workflow_task_timeout_executable.go 10 introduced LOC · 2 ranges

Open complete file

18 executable Executable,
19 workflowTaskTimeoutTask *tasks.WorkflowTaskTimeoutTask,
20 > ) *speculativeWorkflowTaskTimeoutExecutable { speculative_workflow_task_timeout_executable.go
21 >
22 > return &speculativeWorkflowTaskTimeoutExecutable{
23 > Executable: executable,
24 > workflowTaskTimeoutTask: workflowTaskTimeoutTask,
25 > }
26 > }
27
28 // ctasks.Task interface overrides.
go.temporal.io/server/service/history/tasks/workflow_task_timer.go 3 introduced LOC · 1 range

Open complete file

86 d.state.Store(uint32(ctasks.TaskStateCancelled))
87 }
88 > func (d *WorkflowTaskTimeoutTask) State() ctasks.State { workflow_task_timer.go
89 > return ctasks.State(d.state.Load())
90 > }
91
92 func (d *WorkflowTaskTimeoutTask) String() string {