New creates a Backoff object. Pass a Context that can also terminate the operation.
(ctx context.Context, cfg Config)
| 33 | |
| 34 | // New creates a Backoff object. Pass a Context that can also terminate the operation. |
| 35 | func New(ctx context.Context, cfg Config) *Backoff { |
| 36 | return &Backoff{ |
| 37 | cfg: cfg, |
| 38 | ctx: ctx, |
| 39 | nextDelayMin: cfg.MinBackoff, |
| 40 | nextDelayMax: doubleDuration(cfg.MinBackoff, cfg.MaxBackoff), |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | // Reset the Backoff back to its initial condition |
| 45 | func (b *Backoff) Reset() { |