Documentation
¶
Overview ¶
Package lanescheduling implements the Go receiver's local delivery policy. Forecasts, read-ahead admission and rescue timing can evolve independently of other receivers; they grant no content authenticity or resumable progress.
Package lanescheduling owns network supply estimates, authenticated delivery evidence, and bounded exploration. Route permission and transport liveness remain with their existing owners.
Index ¶
- Constants
- func CompareDelivery(left, right DeliveryEstimate) int
- func ConservativeDuration(estimate DeliveryEstimate) time.Duration
- func Cost(estimate time.Duration, factor float64) float64
- func EstimateQueue(load DeliveryLoad) time.Duration
- func FitsReadAhead(estimate DeliveryEstimate, bytes, distance uint64, aggregateRate float64) bool
- func ProbeDue(p *Performance, now time.Time) bool
- type DeliveryEstimate
- type DeliveryEvidence
- type DeliveryLoad
- type DeliveryProgress
- type Exploration
- type Performance
- type Purpose
- type ReceivePermit
- type ReceiveWindow
- func (w *ReceiveWindow) Available() bool
- func (w *ReceiveWindow) EstimateCompletion(bytes uint64, now time.Time) DeliveryEstimate
- func (w *ReceiveWindow) EstimateQueue(now time.Time) time.Duration
- func (w *ReceiveWindow) Load(now time.Time) DeliveryLoad
- func (w *ReceiveWindow) TryReserve(bytes uint64, now time.Time) *ReceivePermit
- func (w *ReceiveWindow) UnfinishedBytes() uint64
- type RescueReason
- type Sampling
- func (s *Sampling) Available(bytes uint64, now time.Time) bool
- func (s *Sampling) Offered(bytes uint64, now time.Time)
- func (s *Sampling) Settled(bytes uint64, now time.Time, outcome SamplingOutcome)
- func (s *Sampling) Snapshot(now time.Time) SamplingEvidence
- func (s *Sampling) Start(now time.Time)
- func (s *Sampling) Stop()
- type SamplingEvidence
- type SamplingOutcome
Constants ¶
const ( InitialBlockTime = 250 * time.Millisecond MinimumSampleTime = time.Millisecond EvidenceLifetime = time.Second MaximumEstimate = time.Hour UserRelayCostFactor = 1.05 RelayCostFactor = 1.1 StaleEvidenceCostFactor = 2 )
const ( ProbeInterval = 5 * time.Second MinimumRescueDelay = 10 * time.Millisecond HedgeDelayFactor = 2 MaximumSupplements = 2 )
const ( SampleLifetime = 12 * time.Second SampleByteBudget uint64 = 8 * 1024 * 1024 SampleAttemptBudget = 8 )
const (
MeasurementWindow = time.Second
)
Variables ¶
This section is empty.
Functions ¶
func CompareDelivery ¶
func CompareDelivery(left, right DeliveryEstimate) int
func ConservativeDuration ¶
func ConservativeDuration(estimate DeliveryEstimate) time.Duration
ConservativeDuration permits bounded revalidation without treating old capacity as current.
func EstimateQueue ¶
func EstimateQueue(load DeliveryLoad) time.Duration
EstimateQueue counts only bytes still expected from the transport.
func FitsReadAhead ¶
func FitsReadAhead(estimate DeliveryEstimate, bytes, distance uint64, aggregateRate float64) bool
FitsReadAhead admits spare capacity only when it should finish before consumption.
Types ¶
type DeliveryEstimate ¶
type DeliveryEstimate struct {
Evidence DeliveryEvidence
Duration time.Duration
}
func EstimateCompletion ¶
func EstimateCompletion(load DeliveryLoad, bytes uint64) DeliveryEstimate
type DeliveryEvidence ¶
type DeliveryEvidence string
const ( DeliveryUnknown DeliveryEvidence = "unknown" DeliveryRecent DeliveryEvidence = "recent" DeliveryStale DeliveryEvidence = "stale" )
type DeliveryLoad ¶
type DeliveryLoad struct {
RemainingBytes uint64
PendingResponses uint32
Evidence DeliveryEvidence
BytesPerSecond float64
Startup time.Duration
}
DeliveryLoad describes network supply, not authenticated plaintext or retained output.
type DeliveryProgress ¶
type Exploration ¶
type Exploration struct {
// contains filtered or unexported fields
}
Exploration grants at most one supplemental attempt per demand (enforced by the caller), and bounds concurrent duplicates across the entire lane set. Probes consume a separate time budget; idle paths need no content to stay open.
func (*Exploration) Available ¶
func (e *Exploration) Available(purpose Purpose, now time.Time) bool
func (*Exploration) NextProbe ¶
func (e *Exploration) NextProbe() time.Time
func (*Exploration) Release ¶
func (e *Exploration) Release(purpose Purpose)
type Performance ¶
type Performance struct {
PendingBytes uint64
BytesPerSecond float64
HasSuccessfulSample bool
LastAttempt time.Time
// contains filtered or unexported fields
}
Performance measures authenticated payload over a lane's busy interval, so overlapping requests do not each claim the lane's entire throughput.
func (*Performance) Begin ¶
func (p *Performance) Begin(now time.Time, bytes uint64)
Begin accounts for unsettled plaintext, independently of remaining network bytes.
func (*Performance) BusyTime ¶
func (p *Performance) BusyTime(now time.Time) time.Duration
BusyTime counts overlapping requests once. Paused jobs and output backpressure must not look like a slow network simply because wall time kept advancing.
func (*Performance) Complete ¶
func (p *Performance) Complete(now time.Time, bytes uint64, successful bool)
func (*Performance) Superseded ¶
func (p *Performance) Superseded(bytes uint64, elapsed time.Duration)
Superseded is a censored observation, not a path failure. It prevents a lane that never finishes before cancellation from retaining an optimistic estimate.
type ReceivePermit ¶
type ReceivePermit struct {
// contains filtered or unexported fields
}
func (*ReceivePermit) Close ¶
func (p *ReceivePermit) Close()
func (*ReceivePermit) Complete ¶
func (p *ReceivePermit) Complete(now time.Time)
func (*ReceivePermit) Progress ¶
func (p *ReceivePermit) Progress(now time.Time) DeliveryProgress
func (*ReceivePermit) Receive ¶
func (p *ReceivePermit) Receive(bytes uint64, now time.Time) bool
Receive updates every fragment's supply estimate and reports a blocked-to-ready transition. Waiters check and reserve under the same owner lock, so another broadcast is unnecessary while capacity stays available.
type ReceiveWindow ¶
type ReceiveWindow struct {
// contains filtered or unexported fields
}
ReceiveWindow owns unfinished responses, independently of authenticated plaintext or output retention. Its caller serializes access with lane state.
func (*ReceiveWindow) Available ¶
func (w *ReceiveWindow) Available() bool
func (*ReceiveWindow) EstimateCompletion ¶
func (w *ReceiveWindow) EstimateCompletion(bytes uint64, now time.Time) DeliveryEstimate
func (*ReceiveWindow) EstimateQueue ¶
func (w *ReceiveWindow) EstimateQueue(now time.Time) time.Duration
func (*ReceiveWindow) Load ¶
func (w *ReceiveWindow) Load(now time.Time) DeliveryLoad
func (*ReceiveWindow) TryReserve ¶
func (w *ReceiveWindow) TryReserve(bytes uint64, now time.Time) *ReceivePermit
func (*ReceiveWindow) UnfinishedBytes ¶
func (w *ReceiveWindow) UnfinishedBytes() uint64
type RescueReason ¶
type RescueReason string
const ( RescueFasterDelivery RescueReason = "faster-delivery" RescueNoProgress RescueReason = "no-progress" RescueBootstrapOverdue RescueReason = "bootstrap-overdue" )
func RescueDecision ¶
func RescueDecision(progress DeliveryProgress, initial, alternative DeliveryEstimate) RescueReason
type Sampling ¶
type Sampling struct {
// contains filtered or unexported fields
}
type SamplingEvidence ¶
type SamplingEvidence struct {
OfferedBytes uint64
SettledBytes uint64
CompletedBytes uint64
CompletedAttempts uint64
FailedAttempts uint64
SupersededAttempts uint64
CancelledAttempts uint64
BusyMilliseconds int64
}
SamplingEvidence counts unique assigned work, separately from authenticated winners and output. Caller cancellation cannot prove a path lacks capacity.
type SamplingOutcome ¶
type SamplingOutcome string
const ( SampleCompleted SamplingOutcome = "completed" SampleFailed SamplingOutcome = "failed" SampleSuperseded SamplingOutcome = "superseded" SampleCancelled SamplingOutcome = "cancelled" )