Documentation
¶
Overview ¶
Package relayplan makes bounded, deterministic relay choices from supplied facts.
Index ¶
Constants ¶
const ( MaximumEndpoints = 8 MaximumNetworkCandidates = 4 TargetNetworkRegistrations = 2 MaximumConcurrentAttempts = 4 ObservationAge = 15 * time.Minute )
const ( BulkCapacityThresholdMbps uint32 = 50 DurationBucket = 100 * time.Millisecond )
Variables ¶
var ErrConfiguration = errors.New("invalid relay plan")
Functions ¶
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
Source Source
Verified bool
IPLiteral bool
// ProbeFailed marks a community candidate whose scoped live probe failed
// recently, keeping it behind unmeasured peers even after short backoff expires.
ProbeFailed bool
CooldownUntil time.Time
ServerRetryAt time.Time
// contains filtered or unexported fields
}
func (Candidate) HistoryState ¶ added in v0.1.5
func (Candidate) ObservedHandshake ¶ added in v0.1.5
ObservedHandshake returns the recent admitted handshake duration used for ranking, reporting false when the candidate was unmeasured or last failed.
func (Candidate) Tier ¶ added in v0.1.7
Tier classifies a candidate's scheduling and startup-wave tier from its source, canary or IP-literal class, and server-requested backoff state.
func (Candidate) WithRegistrationFailure ¶ added in v0.1.6
WithRegistrationFailure marks a candidate copy as failed so live backup arbitration within the same share applies the same ranking rule as Build.
func (Candidate) WithoutRegistrationFailure ¶ added in v0.1.6
WithoutRegistrationFailure clears a failed state once a candidate completes a registration handshake, without inventing a measured duration sample.
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 Input ¶
type Input struct {
Configured []string
Community []Candidate
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
Standby []Candidate
Policy Policy
Decision Decision
}
func (Plan) DirectoryCandidates ¶ added in v0.1.6
DirectoryCandidates returns every directory-sourced candidate in startup wave order (initial Network followed by canary Standby) so consumers that classify or coordinate official relays cannot overlook the standby wave.
func (Plan) NetworkCandidates ¶ added in v0.1.7
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
}
type Tier ¶ added in v0.1.7
type Tier string
const ( TierConfigured Tier = "configured" TierOfficialActive Tier = "official_active" TierOfficialCanary Tier = "official_canary" TierOfficialDeferred Tier = "official_deferred" TierOfficialCanaryDeferred Tier = "official_canary_deferred" TierCommunityNamed Tier = "community_named" TierCommunityIPLiteral Tier = "community_ip_literal" TierCommunityNamedDeferred Tier = "community_named_deferred" TierCommunityIPLiteralDeferred Tier = "community_ip_literal_deferred" )