hop

package
v0.28.2 Latest Latest
Warning

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

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

Overview

Package hop provides a hop (node group) implementation that selects a node from a group of proxy nodes using load-balancing strategies, filters, and bypass rules. It supports periodic reloading of node lists from file, Redis, or HTTP sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHop

func NewHop(opts ...Option) hop.Hop

NewHop creates a new hop with the given options and starts periodic reloading.

func NewHopGroup added in v0.28.1

func NewHopGroup(opts ...HopGroupOption) *hopGroup

NewHopGroup creates a new hopGroup and starts probe goroutines for entries that have probe configurations.

Types

type HopEntry added in v0.28.1

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

HopEntry wraps a hop.Hop with an optional matcher and an independent failure marker for hop-level probe tracking. The entry's marker is separate from any node-level markers inside the hop so that probe Reset() cannot undo a node-level failCodes Mark().

func NewHopEntry added in v0.28.1

func NewHopEntry(h hop.Hop, m routing.Matcher, probe *chain.ProbeConfig) *HopEntry

NewHopEntry creates a HopEntry. matcher may be nil (unconditional catch-all). probe may be nil (no health check for this entry).

func (*HopEntry) Marker added in v0.28.1

func (e *HopEntry) Marker() selector.Marker

Marker implements selector.Markable.

func (*HopEntry) Select added in v0.28.1

func (e *HopEntry) Select(ctx context.Context, opts ...hop.SelectOption) *chain.Node

type HopGroupOption added in v0.28.1

type HopGroupOption func(*hopGroupOptions)

HopGroupOption configures a hopGroup.

func WithEntriesOption added in v0.28.1

func WithEntriesOption(entries ...*HopEntry) HopGroupOption

WithEntriesOption sets the hop entries for the group.

func WithGroupLoggerOption added in v0.28.1

func WithGroupLoggerOption(log logger.Logger) HopGroupOption

WithGroupLoggerOption sets the logger for the group.

func WithGroupSelectorOption added in v0.28.1

func WithGroupSelectorOption(s selector.Selector[hop.Hop]) HopGroupOption

WithGroupSelectorOption sets the selector for the group.

type Option

type Option func(*options)

Option configures a hop.

func BypassOption

func BypassOption(bp bypass.Bypass) Option

BypassOption sets a hop-level bypass that can skip the entire hop.

func FailFilterSettingsOption added in v0.28.1

func FailFilterSettingsOption(maxFails int, timeout time.Duration) Option

FailFilterSettingsOption sets the maxFails/failTimeout used by the hop's FailFilter. The pre-selection dead-node filter consults these to decide whether a node is currently marked failed.

func FileLoaderOption

func FileLoaderOption(fileLoader loader.Loader) Option

FileLoaderOption sets a loader that reads node configs from a file source.

func HTTPLoaderOption

func HTTPLoaderOption(httpLoader loader.Loader) Option

HTTPLoaderOption sets a loader that reads node configs from an HTTP source.

func LoggerOption

func LoggerOption(logger logger.Logger) Option

LoggerOption sets the logger for the hop.

func NameOption

func NameOption(name string) Option

NameOption sets the hop name.

func NodeOption

func NodeOption(nodes ...*chain.Node) Option

NodeOption sets the initial node list for the hop.

func RedisLoaderOption

func RedisLoaderOption(redisLoader loader.Loader) Option

RedisLoaderOption sets a loader that reads node configs from a Redis source.

func ReloadPeriodOption

func ReloadPeriodOption(period time.Duration) Option

ReloadPeriodOption sets the interval for periodic reloading of node lists.

func SelectorOption

func SelectorOption(s selector.Selector[*chain.Node]) Option

SelectorOption sets the load-balancing strategy for node selection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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