spec_processor.go ×8

Frontier kind: Code frontier

unlabeled · c_ad6065cafcd1

95 tests · 5124 LOC · 170 files · introduces 0 tests · 55 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges55 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1161 ranges5124 lines · 170 files · Browse complete extent
All tests (intent)
95 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: 55 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/chasm/lib/scheduler/spec_processor.go 55 introduced LOC · 8 ranges

Open complete file

83 manual bool,
84 limit *int,
85 > ) (*ProcessedTimeRange, error) { spec_processor.go
86 > tweakables := s.config.Tweakables(scheduler.Namespace)
87 > metricsHandler := newTaggedMetricsHandler(s.metricsHandler, scheduler)
88 > overlapPolicy = scheduler.resolveOverlapPolicy(overlapPolicy)
89 >
90 > s.logger.Debug("ProcessTimeRange",
91 > tag.Time("start", start),
92 > tag.Time("end", end),
93 > tag.Any("overlap-policy", overlapPolicy),
94 > tag.Bool("manual", manual))
95 >
96 > // Peek at paused/remaining actions state and don't bother if we're not going to
97 > // take an action now. (Don't count as missed catchup window either.)
98 > // Skip over entire time range if paused or no actions can be taken.
99 > //
100 > // Manual (backfill/patch) runs are always buffered here.
101 > if !scheduler.useScheduledAction(false) && !manual {
102 // Use end as last action time so that we don't reprocess time spent paused.
103 next, err := s.NextTime(scheduler, end)
114 }
115
116 > catchupWindow := catchupWindow(scheduler, tweakables) spec_processor.go
117 >
118 > // lastAction is used to set the high water mark for future ProcessTimeRange
119 > // invocations. The code below will set a "last action" even when none is taken,
120 > // simply to indicate that processing can permanently skip that period of time
121 > // (e.g., it was prior to an update or past a catchup).
122 > lastAction := end
123 >
124 > var next legacyscheduler.GetNextTimeResult
125 > var err error
126 > var bufferedStarts []*schedulespb.BufferedStart
127 > var droppedCount int64
128 > recordedGenerateLatency := false
129 > // Once the buffer fills, drop further automated actions (counted in
130 > // droppedCount) instead of buffering. A non-manual limit already <= 0 means
131 > // the buffer was full on entry, so the whole range drops. Manual (backfill)
132 > // callers pass a positive limit and break to retry the remainder, never drop.
133 > limitReached := limit != nil && !manual && *limit <= 0
134 > computeLimitWarning := false
135 > for next, err = s.NextTime(scheduler, start); err == nil && (!next.Next.IsZero() && !next.Next.After(end)); next, err = s.NextTime(scheduler, next.Next) {
136 computeLimitWarning = computeLimitWarning || next.ComputeLimitWarning
137 lastAction = next.Next
196
197 // Fold any warning seen mid-loop into the terminal result so it isn't lost.
198 > next.ComputeLimitWarning = next.ComputeLimitWarning || computeLimitWarning spec_processor.go
199 > nextWakeup, err := s.checkNextScheduleResult(scheduler, metricsHandler, next, err)
200 > if err != nil {
201 return nil, err
202 }
203
204 > return &ProcessedTimeRange{ spec_processor.go
205 > NextWakeupTime: nextWakeup,
206 > LastActionTime: lastAction,
207 > BufferedStarts: bufferedStarts,
208 > DroppedCount: droppedCount,
209 > }, nil
210 }
211
217 next legacyscheduler.GetNextTimeResult,
218 err error,
219 > ) (time.Time, error) { spec_processor.go
220 > if err == nil {
221 > // Warn (non-fatal) case: the search went long but still resolved.
222 > if next.ComputeLimitWarning {
223 metricsHandler.Counter(metrics.ScheduleComputeLimitWarning.Name()).Record(1)
224 newTaggedLogger(s.logger, scheduler).Warn(
225 "schedule spec next-time search crossed the warn threshold; continuing (spec may be over-excluded)")
226 }
227 > return next.Next, nil spec_processor.go
228 }
229
250
251 // NextTime returns the next time result, or an error if the schedule cannot be compiled.
252 > func (s *SpecProcessorImpl) NextTime(scheduler *Scheduler, after time.Time) (legacyscheduler.GetNextTimeResult, error) { spec_processor.go
253 > spec, err := scheduler.getCompiledSpec(s.specBuilder)
254 > if err != nil {
255 s.logger.Error("Invalid schedule", tag.Error(err))
256 return legacyscheduler.GetNextTimeResult{}, err
257 }
258
259 > return spec.GetNextTime(scheduler.jitterSeed(), after) spec_processor.go
260 }