hosts

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 11 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHostMapper

func NewHostMapper(opts ...Option) hosts.HostMapper

NewHostMapper creates a new HostMapper with the given options. It starts a background goroutine for periodic reload from external loaders.

Types

type Mapping

type Mapping struct {
	Hostname string
	IP       net.IP
}

Mapping is a static mapping from a hostname to an IP address.

type Option

type Option func(opts *options)

Option configures a hostMapper.

func FileLoaderOption

func FileLoaderOption(fileLoader loader.Loader) Option

FileLoaderOption sets a file-based loader for hosts mappings (supports both Loader and Lister).

func HTTPLoaderOption

func HTTPLoaderOption(httpLoader loader.Loader) Option

HTTPLoaderOption sets an HTTP-based loader for hot-reloadable hosts mappings.

func LoggerOption

func LoggerOption(logger logger.Logger) Option

LoggerOption sets the logger for the hostMapper.

func MappingsOption

func MappingsOption(mappings []Mapping) Option

MappingsOption sets the static host-to-IP mappings.

func RedisLoaderOption

func RedisLoaderOption(redisLoader loader.Loader) Option

RedisLoaderOption sets a Redis-based loader for hot-reloadable hosts mappings.

func ReloadPeriodOption

func ReloadPeriodOption(period time.Duration) Option

ReloadPeriodOption sets the period for automatic reload from external loaders.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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