timeout

package
v0.1.147 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: GPL-2.0, GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package timeout provides provider health tracking with sliding-window failure detection and cooldown-based timeout.

Index

Constants

View Source
const DefaultThreshold = 5

DefaultThreshold is the number of failures within the window that triggers a provider timeout. Exported so callers can rely on the package default without repeating the magic number.

View Source
const DefaultWindow = 10 * time.Minute

DefaultWindow is the sliding window duration for failure counting. Exported so callers can rely on the package default without repeating the magic number.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Now       func() time.Time // Clock function; nil defaults to time.Now.
	Threshold int              // failures within window to trigger (default: DefaultThreshold)
	Window    time.Duration    // sliding window (default: DefaultWindow)
	Cooldown  time.Duration    // cooldown after triggering
}

Config holds provider timeout settings.

type ProviderHealth

type ProviderHealth interface {
	IsTimedOut(provider api.ProviderID) bool
	RecordSuccess(provider api.ProviderID)
	RecordFailure(provider api.ProviderID, err error)
	Status() map[api.ProviderID]api.ProviderStatus
	Reset()
}

ProviderHealth abstracts provider timeout tracking.

func New

func New(cfg Config) ProviderHealth

New creates a provider timeout tracker with the given config.

Jump to

Keyboard shortcuts

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