policies

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PathPolicy

type PathPolicy interface {
	Filter(paths []snet.Path) []snet.Path
}

type PerfPolicy

type PerfPolicy interface {
	// Better is a function that takes two paths and decides whether the first
	// one is "better" according to the policy.
	Better(x, y *Stats) bool
}

type Policies

type Policies struct {
	// Path policies are used to determine which paths are eligible and which are not.
	PathPolicy PathPolicy
	// PerfPolicy determines how to select a path if there are several eligible
	// ones. If set to nil, arbitrary path is chosen.
	PerfPolicy PerfPolicy
	// PathCount is the max number of paths to return to the user. Defaults to 1.
	PathCount int
}

Policies is a container for different kinds of policies.

type Stats

type Stats struct {
	// Fingerprint is unique ID of the path. It can be used to achieve consistent ordering
	// and thus prevent random path switching even if all the other path metrics are the same.
	Fingerprint snet.PathFingerprint

	// Latency is median one-way latency of the path.
	Latency time.Duration
	// Jitter is the average of the difference between consecutive latencies.
	Jitter time.Duration
	// DropRate is a percentage of probes with no replies. From interval (0,1).
	DropRate float64

	// Is Alive is true if the probes are passing through at the moment.
	IsAlive bool
	// IsCurrent is true when the path is currently the active one.
	IsCurrent bool
	// IsRevoked is true if a revocation was issued for one or more interfaces on the path.
	IsRevoked bool
}

Stats contains all the metrics about a path.

Jump to

Keyboard shortcuts

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