relayplan

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 7 Imported by: 1 module, 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 relayplan makes bounded, deterministic relay choices from supplied facts.

Index

Constants

View Source
const (
	MaximumEndpoints           = 8
	MaximumNetworkCandidates   = 4
	TargetNetworkRegistrations = 2
	MaximumConcurrentAttempts  = 4
	ObservationAge             = 15 * time.Minute
)
View Source
const (
	BulkCapacityThresholdMbps uint32 = 50
	DurationBucket                   = 100 * time.Millisecond
)

Variables

View Source
var ErrConfiguration = errors.New("invalid relay plan")

Functions

func BackupIndex

func BackupIndex(primary Candidate, candidates []Candidate, policy Policy) int

Types

type Candidate

type Candidate struct {
	URL      string
	Identity string
	Alias    string
	Zone     string
	Region   string
	Provider string
	Operator string

	ObservedDuration time.Duration
	CapacityMbps     uint32
	Canary           bool
	Configured       bool
	CooldownUntil    time.Time
	ServerRetryAt    time.Time
	// contains filtered or unexported fields
}

func (Candidate) HistoryState added in v0.1.5

func (c Candidate) HistoryState() string

func (Candidate) ObservedHandshake added in v0.1.5

func (c Candidate) ObservedHandshake() (time.Duration, bool)

ObservedHandshake returns the recent admitted handshake duration used for ranking, reporting false when the candidate was unmeasured or last failed.

type CooldownReason added in v0.1.5

type CooldownReason string
const (
	CooldownNone             CooldownReason = ""
	CooldownServerBackoff    CooldownReason = "server_backoff"
	CooldownNodeRejected     CooldownReason = "node_rejected"
	CooldownTransportFailure CooldownReason = "transport_failure"
)

type Decision

type Decision struct {
	DirectoryGeneration uint64
	DirectorySerial     uint64
	NetworkGeneration   string
	ConfiguredOnly      bool
	Candidates          []string
	Filters             []Filter
	CooldownFallback    bool
}

type Filter

type Filter struct{ Endpoint, Reason string }

type Input

type Input struct {
	Configured        []string
	Directory         nodedirectory.Payload
	SelectionSeed     string
	Observations      []Observation
	NetworkGeneration string
	Now               time.Time
	Policy            Policy
}

type Observation

type Observation struct {
	Identity          string
	NetworkGeneration string
	At                time.Time
	Admitted          bool
	Duration          time.Duration
	CooldownUntil     time.Time
	CooldownReason    CooldownReason
	ServerRetryAt     time.Time
}

func (Observation) ActiveAt added in v0.1.5

func (o Observation) ActiveAt(now time.Time) Observation

ActiveAt projects historical deadlines into the current scheduling decision.

type Plan

type Plan struct {
	Configured []Candidate
	Network    []Candidate
	Policy     Policy
	Decision   Decision
}

func Build

func Build(input Input) (Plan, error)

type Policy

type Policy struct {
	ConfiguredOnly bool
	// Only measured pair coverage permits preferring two global nodes for a
	// global primary. Exit-location guesses cannot establish receiver reachability.
	GlobalPairCoversMainland bool
	Admit                    func(nodedirectory.Node) bool
}

Jump to

Keyboard shortcuts

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