hosterrors

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxHostsCount = 10000

Variables

View Source
var ErrUnresponsiveHost = errors.New("skipping as host is unresponsive")

ErrUnresponsiveHost is returned when a host is unresponsive

Functions

This section is empty.

Types

type Cache

type Cache struct {
	MaxHostError int

	TrackError []string
	// contains filtered or unexported fields
}

Cache is a cache for host based errors. It allows skipping certain hosts based on an error threshold.

It uses an LRU cache internally for skipping unresponsive hosts that remain so for a duration.

func New

func New(maxHostError, maxHostsCount int, trackError []string) *Cache

New returns a new host max errors cache

func (*Cache) Check

func (c *Cache) Check(value string) bool

Check returns true if a host should be skipped as it has been unresponsive for a certain number of times.

The value should be in host:port format (e.g., "example.com:443").

func (*Cache) Close

func (c *Cache) Close()

Close closes the host errors cache

func (*Cache) MarkFailed

func (c *Cache) MarkFailed(value string, err error, ignoreTimeout bool)

MarkFailed marks a host as failed previously. The value should be in host:port format (e.g., "example.com:443").

func (*Cache) MarkSuccess

func (c *Cache) MarkSuccess(value string)

MarkSuccess resets the error counter for a host on successful request. The value should be in host:port format (e.g., "example.com:443").

func (*Cache) QuarantinedCount

func (c *Cache) QuarantinedCount() int

QuarantinedCount returns the number of hosts that have been marked as unresponsive (error count >= MaxHostError). This is informational only, useful for logging cross-phase host error propagation.

func (*Cache) SetVerbose

func (c *Cache) SetVerbose(verbose bool)

SetVerbose sets the cache to log at verbose level

Jump to

Keyboard shortcuts

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