spec.go ×6

Frontier kind: Code frontier

unlabeled · c_97ac571511ef

196 tests · 2509 LOC · 118 files · introduces 0 tests · 20 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges20 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
400 ranges2509 lines · 118 files · Browse complete extent
All tests (intent)
196 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: 20 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/scheduler/spec.go 20 introduced LOC · 6 ranges

Open complete file

331 }
332
333 > maxJitter := timestamp.DurationValue(cs.spec.Jitter) spec.go
334 > // Ensure that jitter doesn't push this time past the _next_ nominal start time
335 > if following := cs.rawNextTime(nominal); !following.IsZero() {
336 maxJitter = min(maxJitter, following.Sub(nominal))
337 }
338 > next := cs.addJitter(jitterSeed, nominal, maxJitter) spec.go
339 >
340 > return GetNextTimeResult{Nominal: nominal, Next: next, ComputeLimitWarning: warned}, nil
341 }
342
382 }
383 }
384 > return false spec.go
385 }
386
387 // Adds jitter to a nominal time, deterministically (by hashing the given time and a seed).
388 > func (cs *CompiledSpec) addJitter(seed string, nominal time.Time, maxJitter time.Duration) time.Time { spec.go
389 > if maxJitter < 0 {
390 maxJitter = 0
391 }
392
393 > bin, err := nominal.MarshalBinary() spec.go
394 > if err != nil {
395 return nominal
396 }
397
398 > bin = append(bin, []byte(seed)...) spec.go
399 >
400 > // we want to fit the result of a multiply in 64 bits, and use 32 bits of hash, which
401 > // leaves 32 bits for the range. if we use nanoseconds or microseconds, our range is
402 > // limited to only a few seconds or hours. using milliseconds supports up to 49 days.
403 > fp := uint64(farm.Fingerprint32(bin))
404 > ms := min(uint64(maxJitter.Milliseconds()), math.MaxUint32)
405 > jitter := time.Duration((fp*ms)>>32) * time.Millisecond
406 > return nominal.Add(jitter)
407 }