Documentation
¶
Overview ¶
Package lanes owns authenticated block scheduling and the complete lifetime of admitted attempts. Selection, retirement and settlement share one state owner.
Index ¶
- Constants
- Variables
- func AttemptSuperseded(ctx context.Context) bool
- func NewDemandNotAdmitted(cause error) error
- func NewDemandReassignableAfterRetirement(cause error) error
- func NewDemandRetryableAfterRetirement(cause error) error
- type Block
- type BlockCapacitySource
- type BlockReservation
- type BlockSource
- type CapacityBlock
- type CapacityClaim
- type CapacityReadiness
- type Config
- type ContentActivity
- type ContentRoutePolicy
- type ContentSuspension
- type Demand
- type Identity
- type RemainingWork
- type Request
- type Route
- type RouteSupply
- type SchedulingDemand
- type Set
- func (s *Set) Add(identity Identity, route Route, lane BlockSource) error
- func (s *Set) AllowsRoute(route Route) bool
- func (s *Set) BindDownloadMetrics(metrics *downloadmetrics.Metrics)
- func (s *Set) Close()
- func (s *Set) CompleteObservations() SettlementObservationCompletion
- func (s *Set) ContentActivity() []ContentActivity
- func (s *Set) EstimateQueuedContent(identity Identity) time.Duration
- func (s *Set) ExpectRoute(route Route) (*RouteSupply, error)
- func (s *Set) Fetch(ctx context.Context, request Request) (Block, error)
- func (s *Set) HasDelivered(identity Identity) bool
- func (s *Set) Len() int
- func (s *Set) ObserveRemainingWork(snapshot func() RemainingWork) func()
- func (s *Set) RecordOutput(bytes uint64)
- func (s *Set) RecoveryDemand() []Identity
- func (s *Set) Remove(identity Identity) bool
- func (s *Set) SampleLane(identity Identity)
- func (s *Set) SamplingEvidence(identity Identity) (lanescheduling.SamplingEvidence, bool)
- func (s *Set) SchedulingDemand() SchedulingDemand
- func (s *Set) SettlementObservations() observationstream.Consumer[SettlementSummary]
- func (s *Set) Stop()
- func (s *Set) StopSampling(identity Identity)
- func (s *Set) SuspendContent(identity Identity) (*ContentSuspension, error)
- type SettlementObservationCapacity
- type SettlementObservationCompletion
- type SettlementObservationLoss
- type SettlementSummary
- type WorkOrder
- type WorkPriority
Constants ¶
const ( MaxLogicalLanes = 16 MaxDemandAttempts = MaxLogicalLanes )
const DefaultSettlementObservationCapacity = SettlementObservationCapacity(MaxLogicalLanes)
Variables ¶
var ( ErrInvalid = errors.New("transfer lane is invalid") ErrInvalidRequest = errors.New("block request requires a validator") ErrStale = errors.New("transfer lane epoch is stale") ErrBudget = errors.New("transfer lane budget exceeded") ErrClosed = errors.New("transfer lane set is closed") ErrNoContentRoute = errors.New("no permitted content route remains") )
Functions ¶
func AttemptSuperseded ¶
AttemptSuperseded proves that the demand owner canceled a redundant attempt after selecting an authenticated winner. Plain cancellation, including a parent failure, cannot supply this evidence to a lane's terminal diagnostics.
func NewDemandNotAdmitted ¶
func NewDemandRetryableAfterRetirement ¶ added in v0.1.6
Types ¶
type Block ¶
type Block struct {
records.BlockRecord
// contains filtered or unexported fields
}
Block retains the admitted route of the selected authenticated result. Retired incarnations carry Unknown so a late result cannot claim live routing.
func (Block) Route ¶
func (block Block) Route() downloadmetrics.Route
type BlockCapacitySource ¶
type BlockCapacitySource interface {
TryReserveBlock(Demand) (BlockReservation, <-chan struct{}, error)
}
BlockCapacitySource reserves response storage before any request is sent. A source without storage (for example, an in-memory source) needs no claim.
type BlockReservation ¶
type BlockReservation struct {
Source BlockSource
Release func()
}
type BlockSource ¶
type CapacityBlock ¶
type CapacityBlock uint8
CapacityBlock distinguishes waiting for transport supply from local holdings. Connectivity must not grow paths to solve consumer or memory backpressure.
const ( CapacityReady CapacityBlock = iota CapacityNetwork CapacityBackoff CapacityRoute CapacityConsumer )
type CapacityClaim ¶
type CapacityClaim func() (release func(), changed <-chan struct{}, err error)
CapacityClaim reserves one physical attempt before its source is called. A nil release with a change signal means admission must wait. Release remains owned by the attempt until its plaintext is handed back or discarded.
type CapacityReadiness ¶
type CapacityReadiness struct {
Kind CapacityBlock
Changed <-chan struct{}
}
type Config ¶
type Config struct {
ContentRoutePolicy ContentRoutePolicy
ProtocolSessionID protocolsession.ProtocolSessionID
Now func() time.Time
After func(time.Duration) <-chan time.Time
SettlementObservationCapacity SettlementObservationCapacity
}
type ContentActivity ¶
type ContentActivity struct {
Route Route
UsefulBytes uint64
LastUsefulAt time.Time
AdmittedLanes uint32
}
ContentActivity counts only selected authenticated block results. Open channels, discarded race losers and ciphertext never imply useful traffic.
type ContentRoutePolicy ¶
type ContentRoutePolicy uint8
ContentRoutePolicy is fixed before a session admits content. Keeping it on the set means replacement epochs and new lane IDs cannot bypass user intent.
const ( ContentRouteAll ContentRoutePolicy = iota ContentRouteDirectOnly ContentRouteRelayOnly )
func (ContentRoutePolicy) Allows ¶
func (policy ContentRoutePolicy) Allows(route Route) bool
type ContentSuspension ¶
type ContentSuspension struct {
// contains filtered or unexported fields
}
ContentSuspension is an epoch-stable content-admission capability for one authenticated logical lane. Its opaque policy identity prevents an old handle from releasing a newer hold on the same lane ID.
func (*ContentSuspension) Resume ¶
func (suspension *ContentSuspension) Resume() error
Resume releases only the hold represented by this capability. It is idempotent so concurrent admission signals cannot release a later policy.
type Demand ¶
type Demand struct {
LeaseID content.LeaseID
Descriptor content.FileRevisionDescriptor
Index uint64
}
type RemainingWork ¶
type Request ¶
type Request struct {
Demand Demand
Validate func(records.BlockRecord) error
Claim CapacityClaim
Order func() WorkOrder
Ready func() CapacityReadiness
}
Request binds an immutable block demand to the consumer's validation and capacity authority. Validation must return a typed fault for known failures; lane scheduling cannot infer consumer policy from diagnostic error strings.
type Route ¶
type Route uint8
Route is the authenticated content route admitted for one lane incarnation. It is captured at admission because lane numbers carry no transport meaning and may be reused across epochs.
func (Route) DiagnosticName ¶
DiagnosticName belongs to the source vocabulary; recorders accept new values.
type RouteSupply ¶
type RouteSupply struct {
// contains filtered or unexported fields
}
RouteSupply is the lifetime of an owner actively provisioning or recovering permitted content paths. It is not evidence that any existing lane is usable.
func (*RouteSupply) Close ¶
func (supply *RouteSupply) Close()
type SchedulingDemand ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func (*Set) AllowsRoute ¶ added in v0.1.6
AllowsRoute exposes the session's immutable content policy to connectivity.
func (*Set) BindDownloadMetrics ¶
func (s *Set) BindDownloadMetrics(metrics *downloadmetrics.Metrics)
BindDownloadMetrics is called before content activation, once per generation.
func (*Set) Close ¶
func (s *Set) Close()
Close is the external ownership boundary. Attempt callbacks call Stop because synchronously joining their own attempt would prevent its deferred completion.
func (*Set) CompleteObservations ¶
func (s *Set) CompleteObservations() SettlementObservationCompletion
CompleteObservations returns the producer-owned settlement cut. Close first joins lane work so no new summary can be admitted while this result is read.
func (*Set) ContentActivity ¶
func (s *Set) ContentActivity() []ContentActivity
func (*Set) EstimateQueuedContent ¶
EstimateQueuedContent exposes scheduling evidence, not route permission. Control requests remain usable while a lane is suspended for content-only policy.
func (*Set) ExpectRoute ¶
func (s *Set) ExpectRoute(route Route) (*RouteSupply, error)
ExpectRoute lets queued demand survive a gap between connection generations. The connectivity owner must close the capability when its recovery work ends; a forbidden route can never acquire one, regardless of transport liveness.
func (*Set) Fetch ¶
Fetch returns the first consumer-validated block. Canceled competing attempts retain their capacity until they exit; Close joins that remaining ownership.
func (*Set) HasDelivered ¶ added in v0.1.6
HasDelivered reports whether this exact live lane incarnation has completed at least one authenticated block read. Connectivity uses it to confirm that a stall-recovered transport actually delivers content before resetting retries.
func (*Set) ObserveRemainingWork ¶
func (s *Set) ObserveRemainingWork(snapshot func() RemainingWork) func()
ObserveRemainingWork follows a job, rather than mistaking its bounded range window for the complete selection. Discovery can remain open indefinitely.
func (*Set) RecordOutput ¶
Output advances after the materializer accepts a range, independently of receipt, authentication, and crash-durable checkpoint progress.
func (*Set) RecoveryDemand ¶
RecoveryDemand identifies exact live generations that exhausted a queued immutable read. Healthy in-flight work and consumer backpressure do not grant recovery authority. The connection owner rechecks the identity before acting.
func (*Set) SampleLane ¶
SampleLane grants a bounded opportunity, not a fixed traffic share. Allocation still owns route eligibility, output-frontier priority and physical capacity.
func (*Set) SamplingEvidence ¶
func (s *Set) SamplingEvidence(identity Identity) (lanescheduling.SamplingEvidence, bool)
func (*Set) SchedulingDemand ¶
func (s *Set) SchedulingDemand() SchedulingDemand
func (*Set) SettlementObservations ¶
func (s *Set) SettlementObservations() observationstream.Consumer[SettlementSummary]
SettlementObservations returns nil when settlement observation was disabled. The receive-only capability leaves publication and completion with Set.
func (*Set) Stop ¶
func (s *Set) Stop()
Stop closes admission and cancels attempts without waiting. BlockSource callbacks use it when a lane-local failure must terminate the whole set.
func (*Set) StopSampling ¶
func (*Set) SuspendContent ¶
func (s *Set) SuspendContent(identity Identity) (*ContentSuspension, error)
SuspendContent removes an authenticated logical lane from content admission without detaching its control transport. The initial exact identity prevents suspending an unintended incarnation, while the returned capability follows replacements because reconnects must not bypass an active admission policy.
type SettlementObservationCapacity ¶
type SettlementObservationCapacity int
SettlementObservationCapacity is the exact number of summaries retained while the owner-selected consumer is not receiving. Zero disables settlement accounting and stream allocation.
type SettlementObservationCompletion ¶
type SettlementObservationCompletion struct {
Enqueued uint64
Loss SettlementObservationLoss
}
type SettlementObservationLoss ¶
type SettlementObservationLoss struct {
CapacityDropped uint64
}
SettlementObservationLoss names every producer-owned omission without merging lane identities into a synthetic summary.
func (SettlementObservationLoss) Total ¶
func (loss SettlementObservationLoss) Total() uint64
type SettlementSummary ¶
type SettlementSummary struct {
ProtocolSessionID protocolsession.ProtocolSessionID
Route Route
Lane Identity
DeliveredBlocks uint64
DeliveredBytes uint64
FailedBlockAttempts uint64
ReassignedBlocks uint64
Incomplete bool
}
SettlementSummary is deliberately aggregate and text-free. The source contract excludes file and block identities so diagnostics cannot become a second content-access path.
func (SettlementSummary) DiagnosticRecord ¶
func (v SettlementSummary) DiagnosticRecord() diag.Record
type WorkOrder ¶
type WorkOrder struct {
Priority WorkPriority
Distance uint64
LastServed uint64
}
Distance follows the consumer's output frontier; LastServed orders independent consumers fairly without reserving a fixed share of traffic for any of them.