Documentation
¶
Overview ¶
Package nativepeer assembles demand-owned native connectivity resources. It reports changed facts; the PeerSet alone decides whether to start an attempt.
Index ¶
- Constants
- Variables
- func GenerationIdentity(generation uint64) (identity [16]byte)
- type Admission
- type AdmissionClock
- type AdmissionFacts
- type AdmissionKind
- type AttemptRequest
- type Change
- type Config
- type LifecycleFacts
- type LifecycleKind
- type NativePeerConnectivity
- func (n *NativePeerConnectivity) ApplyControl(session [16]byte, body []byte) (protocolsession.PeerPathControl, bool)
- func (n *NativePeerConnectivity) BeginWave(session [16]byte, pathID v2signal.PeerPathID)
- func (n *NativePeerConnectivity) ClaimPrewarm(session [16]byte) bool
- func (n *NativePeerConnectivity) Close(ctx context.Context) error
- func (n *NativePeerConnectivity) ClosePath(session [16]byte, path v2signal.PeerPathID)
- func (n *NativePeerConnectivity) CloseSession(session [16]byte)
- func (n *NativePeerConnectivity) CompleteObservations() observationstream.Completion
- func (n *NativePeerConnectivity) Control(session [16]byte, pathID v2signal.PeerPathID, ...) ([]byte, error)
- func (n *NativePeerConnectivity) Generation(session [16]byte, path v2signal.PeerPathID) uint64
- func (n *NativePeerConnectivity) Idle(ctx context.Context, session [16]byte, pathID v2signal.PeerPathID, ...)
- func (n *NativePeerConnectivity) Maintain(ctx context.Context)
- func (n *NativePeerConnectivity) NetworkGeneration() uint64
- func (n *NativePeerConnectivity) NewPeerConnection(ctx context.Context, request AttemptRequest) (*pionpeer.Connection, error)
- func (n *NativePeerConnectivity) Observations() <-chan Observation
- func (n *NativePeerConnectivity) ObserveContentRecovery(subject Subject, direct bool)
- func (n *NativePeerConnectivity) ObserveParallelism(subject Subject, decision throughput.Decision, demand throughput.Observation)
- func (n *NativePeerConnectivity) ObserveTURN(event turnpath.Event)
- func (n *NativePeerConnectivity) PrepareAttempt(ctx context.Context, request AttemptRequest) (*PreparedAttempt, error)
- func (n *NativePeerConnectivity) Retired(session [16]byte, pathID v2signal.PeerPathID) bool
- func (n *NativePeerConnectivity) RunSession(ctx context.Context, session [16]byte, ...)
- func (n *NativePeerConnectivity) SetAdmitted(session [16]byte, pathID v2signal.PeerPathID, direct bool)
- func (n *NativePeerConnectivity) SetDemand(session [16]byte, path v2signal.PeerPathID, content, direct bool) (<-chan Change, error)
- type NetworkMonitor
- type Observation
- type ParallelismFacts
- type PreparedAttempt
- type Subject
Constants ¶
const ( ConcurrentAttempts = 4 DirectAttemptReserve = 1 StartsPerWindow = 16 STUNEndpointsPerWindow = 32 MaximumQueuedAttempts = 64 AdmissionWindow = time.Minute AttemptBudget = 85 * time.Second ActiveTimePerWindow = ConcurrentAttempts * AttemptBudget QueueBudget = time.Minute MinimumPreparationOpportunity = 50 * time.Second MaximumSTUNEndpointsPerAttempt = icepolicy.EndpointsPerProfile )
These application limits mirror browser tab admission. The injected authority survives manager, authenticated-session and network-generation replacement.
const ( InitialCheckingBudget = 40 * time.Second MaximumPaths = 64 WaveLifetime = 120 * time.Second )
const ( DefaultObservationCapacity = 256 SideSender = "sender" SideReceiver = "receiver" )
const ControlLifetime = 60 * time.Second
const ControlRefresh = 30 * time.Second
const MaintenanceInterval = 250 * time.Millisecond
Variables ¶
var ErrAdmission = errors.New("native attempt admission unavailable")
var ErrCapacityRequired = errors.New("native connectivity requires admission and TURN capacity")
Functions ¶
func GenerationIdentity ¶
Types ¶
type Admission ¶
type Admission struct {
// contains filtered or unexported fields
}
Admission belongs to the application; every native owner shares its allowances. Replacing a connection manager must not replenish the application's rate budget.
func NewAdmission ¶
func NewAdmission(clock AdmissionClock) *Admission
type AdmissionClock ¶
AdmissionClock permits deterministic refill and queue tests without sleeping.
type AdmissionFacts ¶
type AdmissionFacts struct {
Purpose v2signal.ConnectionPurpose
Kind AdmissionKind
At time.Time
Wait time.Duration
Active, Queued int
StartsRemaining, STUNRemaining float64
ActiveTimeRemaining time.Duration
SocketCapacity *socketauthority.CapacityError
}
type AdmissionKind ¶
type AdmissionKind string
const ( AdmissionQueued AdmissionKind = "queued" AdmissionGranted AdmissionKind = "granted" AdmissionReleased AdmissionKind = "released" AdmissionRejected AdmissionKind = "rejected" )
type AttemptRequest ¶
type AttemptRequest struct {
Configuration pion.Configuration
ICE iceconfig.Connection
ProtocolSessionID [16]byte
ReplacesPeerPathID [16]byte
Binding v2signal.Binding
OnTURNRecovery func(turncontrol.RecoveryReason)
}
type Config ¶
type Config struct {
Admission *Admission
TURNCapacity *turncapacity.Pool
Connect func(pion.Configuration, pionpeer.AttemptConfig) (*pionpeer.Connection, error)
Monitor NetworkMonitor
Sockets *socketauthority.Authority
Pool func() icepolicy.ICEEndpointPool
Reachability *reachability.Authority
Discovery *gateway.Discovery
Now func() time.Time
ObservationCapacity int
Side string
}
type LifecycleFacts ¶
type LifecycleKind ¶
type LifecycleKind string
const ( DemandChanged LifecycleKind = "demand_changed" NetworkChanged LifecycleKind = "network_changed" PathClosed LifecycleKind = "path_closed" ContentRecoveryRequested LifecycleKind = "content_recovery_requested" )
type NativePeerConnectivity ¶
type NativePeerConnectivity struct {
// contains filtered or unexported fields
}
func New ¶
func New(config Config) (*NativePeerConnectivity, error)
func (*NativePeerConnectivity) ApplyControl ¶
func (n *NativePeerConnectivity) ApplyControl(session [16]byte, body []byte) (protocolsession.PeerPathControl, bool)
ApplyControl sees only the core runtime's authenticated canonical body. A watermark survives expiry/revoke so late delivery cannot resurrect demand.
func (*NativePeerConnectivity) BeginWave ¶
func (n *NativePeerConnectivity) BeginWave(session [16]byte, pathID v2signal.PeerPathID)
func (*NativePeerConnectivity) ClaimPrewarm ¶
func (n *NativePeerConnectivity) ClaimPrewarm(session [16]byte) bool
A speculative opportunity belongs to the authenticated session, even when its receiver constructs another PeerSet after the first path finishes.
func (*NativePeerConnectivity) Close ¶
func (n *NativePeerConnectivity) Close(ctx context.Context) error
func (*NativePeerConnectivity) ClosePath ¶
func (n *NativePeerConnectivity) ClosePath(session [16]byte, path v2signal.PeerPathID)
func (*NativePeerConnectivity) CloseSession ¶
func (n *NativePeerConnectivity) CloseSession(session [16]byte)
func (*NativePeerConnectivity) CompleteObservations ¶
func (n *NativePeerConnectivity) CompleteObservations() observationstream.Completion
func (*NativePeerConnectivity) Control ¶
func (n *NativePeerConnectivity) Control(session [16]byte, pathID v2signal.PeerPathID, kind protocolsession.PeerPathControlKind, content bool) ([]byte, error)
func (*NativePeerConnectivity) Generation ¶
func (n *NativePeerConnectivity) Generation(session [16]byte, path v2signal.PeerPathID) uint64
func (*NativePeerConnectivity) Idle ¶
func (n *NativePeerConnectivity) Idle(ctx context.Context, session [16]byte, pathID v2signal.PeerPathID, until time.Time)
Idle transfers only a previously reserved attempt's bounded wait to the socket authority. DNS failure never turns into a transport retry decision.
func (*NativePeerConnectivity) Maintain ¶
func (n *NativePeerConnectivity) Maintain(ctx context.Context)
Maintain is called by the demand owner. It never creates a PeerConnection or renews the application's demand lifetime.
func (*NativePeerConnectivity) NetworkGeneration ¶
func (n *NativePeerConnectivity) NetworkGeneration() uint64
NetworkGeneration includes snapshots without a live path, so exhausted recovery budgets can be reconsidered after the network changes.
func (*NativePeerConnectivity) NewPeerConnection ¶
func (n *NativePeerConnectivity) NewPeerConnection(ctx context.Context, request AttemptRequest) (*pionpeer.Connection, error)
func (*NativePeerConnectivity) Observations ¶
func (n *NativePeerConnectivity) Observations() <-chan Observation
func (*NativePeerConnectivity) ObserveContentRecovery ¶
func (n *NativePeerConnectivity) ObserveContentRecovery(subject Subject, direct bool)
func (*NativePeerConnectivity) ObserveParallelism ¶
func (n *NativePeerConnectivity) ObserveParallelism(subject Subject, decision throughput.Decision, demand throughput.Observation)
func (*NativePeerConnectivity) ObserveTURN ¶
func (n *NativePeerConnectivity) ObserveTURN(event turnpath.Event)
ObserveTURN shares the bounded native diagnostic stream while preserving the path's identity even before an ICE attempt exists.
func (*NativePeerConnectivity) PrepareAttempt ¶
func (n *NativePeerConnectivity) PrepareAttempt(ctx context.Context, request AttemptRequest) (*PreparedAttempt, error)
func (*NativePeerConnectivity) Retired ¶
func (n *NativePeerConnectivity) Retired(session [16]byte, pathID v2signal.PeerPathID) bool
func (*NativePeerConnectivity) RunSession ¶
func (n *NativePeerConnectivity) RunSession(ctx context.Context, session [16]byte, send func(context.Context, []byte) error)
RunSession maintains demand facts only; it cannot allocate attempts.
func (*NativePeerConnectivity) SetAdmitted ¶
func (n *NativePeerConnectivity) SetAdmitted(session [16]byte, pathID v2signal.PeerPathID, direct bool)
func (*NativePeerConnectivity) SetDemand ¶
func (n *NativePeerConnectivity) SetDemand(session [16]byte, path v2signal.PeerPathID, content, direct bool) (<-chan Change, error)
Demand is the only authority for gateway work. Browsing can allocate an ICE path but cannot turn a speculative connection into a router mapping request.
type NetworkMonitor ¶
type Observation ¶
type Observation struct {
Subject Subject
Provider *pionpeer.Event
Reachability *reachability.Event
Lifecycle *LifecycleFacts
Admission *AdmissionFacts
Socket *socketauthority.Event
TURN *turnpath.Event
Parallelism *ParallelismFacts
}
An absent identity means unknown attribution. A path-owned gateway operation can outlive an attempt, so it never borrows the currently active attempt ID.
func (Observation) DiagnosticRecord ¶
func (value Observation) DiagnosticRecord() diag.Record
type ParallelismFacts ¶
type ParallelismFacts struct {
At time.Time
Decision throughput.Decision
Demand throughput.Observation
}
type PreparedAttempt ¶
type PreparedAttempt struct {
// contains filtered or unexported fields
}
PreparedAttempt owns an admitted application opportunity. Separation from Start lets receivers queue before signaling; an incoming sender offer instead queues within its already-running preparation deadline. Neither spends ICE time.
func (*PreparedAttempt) Close ¶
func (p *PreparedAttempt) Close()
Close abandons a preparation which has not transferred to a pionpeer. Once Start succeeds, provider close or authenticated lane admission settles it.
func (*PreparedAttempt) Matches ¶
func (p *PreparedAttempt) Matches(session [16]byte, binding v2signal.Binding) bool
func (*PreparedAttempt) Start ¶
func (p *PreparedAttempt) Start(ctx context.Context) (*pionpeer.Connection, error)