MCPcopy Create free account
hub / github.com/cortexproject/cortex / nextInterval

Method nextInterval

pkg/util/time.go:212–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210}
211
212func (t *SlottedTicker) nextInterval() time.Duration {
213 slotIndex, totalSlots := t.sf()
214
215 // Discover what time the last iteration started
216 lastStartTime := time.UnixMilli((time.Now().UnixMilli() / t.d.Milliseconds()) * t.d.Milliseconds())
217 offset := time.Duration((float64(slotIndex) / float64(totalSlots)) * float64(t.d))
218 // Lets offset the time of the iteration
219 lastStartTime = lastStartTime.Add(offset)
220
221 // Keep adding the ticker duration until we pass time.now
222 for lastStartTime.Before(time.Now()) {
223 lastStartTime = lastStartTime.Add(t.d)
224 }
225
226 slotSize := t.d / time.Duration(totalSlots)
227 return time.Until(lastStartTime) + PositiveJitter(slotSize, t.slotJitter)
228}
229
230func ParseDurationMs(s string) (int64, error) {
231 if d, err := strconv.ParseFloat(s, 64); err == nil {

Callers 1

NewSlottedTickerFunction · 0.95

Calls 3

PositiveJitterFunction · 0.85
BeforeMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected