...

Package backoffutils

import "github.com/grpc-ecosystem/go-grpc-middleware/util/backoffutils"
Overview
Index

Overview ▾

Backoff Helper Utilities

Implements common backoff features.

func ExponentBase2

func ExponentBase2(a uint) uint

ExponentBase2 computes 2^(a-1) where a >= 1. If a is 0, the result is 0.

func JitterUp

func JitterUp(duration time.Duration, jitter float64) time.Duration

JitterUp adds random jitter to the duration.

This adds or subtracts time from the duration within a given jitter fraction. For example for 10s and jitter 0.1, it will return a time within [9s, 11s])