Documentation
¶
Index ¶
- func AddJitterToDuration(d time.Duration) time.Duration
- func GetLocalTimezoneOffsetNsecs() int64
- func ParseDuration(s string) (time.Duration, error)
- func ParseTimeAt(s string, currentTimestamp int64) (int64, error)
- func ParseTimeMsec(s string) (int64, error)
- func TryParseUnixTimestamp(s string) (int64, bool)
- type BackoffTimer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddJitterToDuration ¶
AddJitterToDuration adds up to 10% random jitter to d and returns the resulting duration.
The maximum jitter is limited by 10 seconds.
func GetLocalTimezoneOffsetNsecs ¶ added in v1.97.9
func GetLocalTimezoneOffsetNsecs() int64
GetLocalTimezoneOffsetNsecs returns local timezone offset in nanoseconds.
func ParseDuration ¶ added in v1.102.15
ParseDuration parses duration string in Prometheus format
func ParseTimeAt ¶ added in v1.102.15
ParseTimeAt parses time s in different formats, assuming the given currentTimestamp.
See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#timestamp-formats
If s doesn't contain timezone information, then the local timezone is used. The time must be in the range [1970-01-01T00:00:00Z, 2262-04-11T23:47:16Z].
It returns unix timestamp in nanoseconds.
func ParseTimeMsec ¶ added in v1.102.15
ParseTimeMsec parses time s in different formats.
See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#timestamp-formats
It returns unix timestamp in milliseconds.
func TryParseUnixTimestamp ¶ added in v1.102.25
TryParseUnixTimestamp parses s as unix timestamp in seconds, milliseconds, microseconds or nanoseconds and returns the parsed timestamp in nanoseconds.
The supported formats for s:
- Integer. For example, 1234567890 - Fractional. For example, 1234567890.123 - Scientific. For example, 1.23456789e9
Types ¶
type BackoffTimer ¶ added in v1.122.19
type BackoffTimer struct {
// contains filtered or unexported fields
}
BackoffTimer implements an exponential backoff timer with jitter.
func NewBackoffTimer ¶ added in v1.122.19
func NewBackoffTimer(minDelay, maxDelay time.Duration) *BackoffTimer
NewBackoffTimer returns a new BackoffTimer initialized with the given minDelay and maxDelay.
func (*BackoffTimer) CurrentDelay ¶ added in v1.122.19
func (bt *BackoffTimer) CurrentDelay() time.Duration
CurrentDelay returns the current backoff duration.
func (*BackoffTimer) Reset ¶ added in v1.122.19
func (bt *BackoffTimer) Reset()
Reset sets the backoff delay to its minimum.
func (*BackoffTimer) SetDelay ¶ added in v1.122.19
func (bt *BackoffTimer) SetDelay(d time.Duration)
SetDelay overrides the current delay. Useful for respecting Retry-After headers.
func (*BackoffTimer) Wait ¶ added in v1.122.19
func (bt *BackoffTimer) Wait(stopCh <-chan struct{}) bool
Wait sleeps for the current delay with jitter, doubling the delay for the next Wait. Use CurrentDelay to get the current backoff duration.
Wait returns false if stopCh is closed.