cooldown

package
v1.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cooldown holds back upstream targets whose vendor answered 429 or 503 with Retry-After, so routing skips them without network IO until it expires.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a per-replica set of pauses. Like the circuit breaker it is not shared: each replica pays at most one rejected call per pause window.

func New

func New(max time.Duration) *Store

New returns a store that honours Retry-After up to max, or nil when max is not positive, which disables pauses.

func (*Store) Idle

func (s *Store) Idle() bool

Idle reports that nothing is paused, letting callers skip building keys.

func (*Store) Pause

func (s *Store) Pause(key string, d time.Duration) time.Duration

Pause holds key off for d, capped at the configured maximum. It never shortens a pause already running and returns the one now in force.

func (*Store) Remaining

func (s *Store) Remaining(key string) time.Duration

Remaining is how long key stays paused, zero when it is not.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL