Documentation
¶
Overview ¶
Package sendersession owns sharing-side session admission, catalog and content services, and orderly shutdown.
Index ¶
- Constants
- type CatalogFactory
- type CatalogFactoryFunc
- type ChannelAdmission
- type ChannelKind
- type ContentFactory
- type ContentFactoryFunc
- type Factory
- func (factory *Factory) Accept(ctx context.Context, channel protocolsession.FrameChannel) (*Runtime, error)
- func (factory *Factory) ActiveSessions() int
- func (factory *Factory) AdmitChannel(ctx context.Context, channel protocolsession.FrameChannel) (ChannelAdmission, error)
- func (factory *Factory) Attach(ctx context.Context, channel protocolsession.FrameChannel) (session.LaneIdentity, error)
- func (factory *Factory) BeginStop(message string) error
- func (factory *Factory) Stop(ctx context.Context, message string) error
- func (factory *Factory) String() string
- type FactoryConfig
- type InitialLaneIDSource
- type InitialLaneIDSourceFunc
- type PeerAdmissionControl
- type PeerAdmissionControlFunc
- type PeerAdmissionDisposition
- type PeerAdmissionResult
- type PeerHandler
- type PeerHandlerFactory
- type PeerHandlerFactoryFunc
- func (function PeerHandlerFactoryFunc) BeginOperationContinuation(protocolsession.MessageKind, []byte) (protocolsession.OperationContinuationContract, bool, error)
- func (function PeerHandlerFactoryFunc) ClassifyUnboundOperationContinuation(protocolsession.MessageKind, []byte) (protocolsession.OperationContinuationScope, bool, error)
- func (function PeerHandlerFactoryFunc) NewSenderPeerHandler(peer PeerSession) (PeerHandler, error)
- type PeerLaneAttachment
- type PeerResponseDelivery
- type PeerSession
- type Runtime
- func (runtime *Runtime) AdmitPeerChannel(ctx context.Context, channel protocolsession.FrameChannel, ...) (PeerAdmissionResult, error)
- func (runtime *Runtime) AttachedLanes() int
- func (runtime *Runtime) BeginClose()
- func (runtime *Runtime) BeginStop(ctx context.Context, message string) error
- func (runtime *Runtime) Close()
- func (runtime *Runtime) DetachLane(identity session.LaneIdentity) bool
- func (runtime *Runtime) Done() <-chan struct{}
- func (runtime *Runtime) Err() error
- func (runtime *Runtime) LaneDone(identity session.LaneIdentity) (<-chan struct{}, bool)
- func (runtime *Runtime) LaneIdentity() (uint32, uint32)
- func (runtime *Runtime) LaneRegistry() *protocolsession.LaneRegistry
- func (runtime *Runtime) Lifetime() context.Context
- func (runtime *Runtime) ProtocolSessionID() protocolsession.ProtocolSessionID
- func (runtime *Runtime) SetPeerPathControlHandler(handler func(context.Context, []byte) error)
- func (runtime *Runtime) SetTURNControlHandler(handler func(context.Context, []byte) error)
- func (runtime *Runtime) Stop(ctx context.Context, message string) error
- func (runtime *Runtime) Stopping() bool
- func (runtime *Runtime) WaitClosed()
- func (runtime *Runtime) WaitStopped(ctx context.Context) error
- type TerminalConnectivity
- type TerminalConnectivityFuncs
Constants ¶
const DefaultTerminalCleanupTimeout = 15 * time.Second
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatalogFactory ¶
type CatalogFactory interface {
NewSenderCatalogService() (*catalogflow.AddressedSenderService, error)
}
type CatalogFactoryFunc ¶
type CatalogFactoryFunc func() (*catalogflow.AddressedSenderService, error)
func (CatalogFactoryFunc) NewSenderCatalogService ¶
func (function CatalogFactoryFunc) NewSenderCatalogService() (*catalogflow.AddressedSenderService, error)
type ChannelAdmission ¶
type ChannelAdmission struct {
Kind ChannelKind
Session *Runtime
Lane session.LaneIdentity
}
type ChannelKind ¶
type ChannelKind uint8
const ( ChannelNewProtocolSession ChannelKind = iota + 1 ChannelAttachedLane )
type ContentFactory ¶
type ContentFactory interface {
NewSenderContentService(protocolsession.ProtocolSessionID) (*contentflow.SenderService, error)
}
type ContentFactoryFunc ¶
type ContentFactoryFunc func(protocolsession.ProtocolSessionID) (*contentflow.SenderService, error)
func (ContentFactoryFunc) NewSenderContentService ¶
func (function ContentFactoryFunc) NewSenderContentService( sessionID protocolsession.ProtocolSessionID, ) (*contentflow.SenderService, error)
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
func NewFactory ¶
func NewFactory(config FactoryConfig) (*Factory, error)
func (*Factory) Accept ¶
func (factory *Factory) Accept(ctx context.Context, channel protocolsession.FrameChannel) (*Runtime, error)
func (*Factory) ActiveSessions ¶
func (*Factory) AdmitChannel ¶
func (factory *Factory) AdmitChannel( ctx context.Context, channel protocolsession.FrameChannel, ) (ChannelAdmission, error)
AdmitChannel owns the first-frame dispatch boundary for opaque relay and P2P channels. A valid WS2A can only attach to a still-live ProtocolSession; every other candidate must prove a fresh WS2C transcript before it becomes a new session. Keeping this decision beside both authenticators prevents a transport owner from routing on untrusted session identities.
func (*Factory) Attach ¶
func (factory *Factory) Attach( ctx context.Context, channel protocolsession.FrameChannel, ) (session.LaneIdentity, error)
Attach routes an untrusted WS2A only far enough to find its live ProtocolSession. Unknown/malformed candidates are closed without a response; all signed responses remain behind LaneRegistry's traffic-key proof.
type FactoryConfig ¶
type FactoryConfig struct {
SessionAuthKey []byte
SenderPrivateKey ed25519.PrivateKey
Catalog CatalogFactory
Content ContentFactory
Peers PeerHandlerFactory
ReplayGuard *protocolsession.ClientHelloReplayGuard
Random io.Reader
InitialLaneIDs InitialLaneIDSource
OperationLimits protocolsession.OperationLimits
RouterLimits protocolsession.RouterLimits
Now func() time.Time
TerminalConnectivity TerminalConnectivity
TerminalTimeout time.Duration
TerminalSendObserver sessionobs.SenderTerminalSendObserver
SessionTerminalObserver sessionobs.SenderSessionTerminalObserver
ProtocolObservations observationstream.Producer[sessionobs.ProtocolObservation]
}
type InitialLaneIDSource ¶
type InitialLaneIDSourceFunc ¶
func (InitialLaneIDSourceFunc) NextInitialLaneID ¶
func (function InitialLaneIDSourceFunc) NextInitialLaneID() (uint32, error)
type PeerAdmissionControl ¶
type PeerAdmissionControl interface {
BeginAuthenticatedSettlement(protocolsession.OperationID, session.LaneIdentity) bool
}
PeerAdmissionControl owns the attempt's one-shot transition from admission-waiting to admission-settling. Core calls it only after WS2A has authenticated and before it consumes/rejects a grant or sends signed evidence.
type PeerAdmissionControlFunc ¶
type PeerAdmissionControlFunc func(protocolsession.OperationID, session.LaneIdentity) bool
func (PeerAdmissionControlFunc) BeginAuthenticatedSettlement ¶
func (function PeerAdmissionControlFunc) BeginAuthenticatedSettlement( operationID protocolsession.OperationID, lane session.LaneIdentity, ) bool
type PeerAdmissionDisposition ¶
type PeerAdmissionDisposition uint8
const ( PeerAdmissionSilentClose PeerAdmissionDisposition = iota + 1 PeerAdmissionAccepted PeerAdmissionRejected )
type PeerAdmissionResult ¶
type PeerAdmissionResult struct {
SettlementBegan bool
GrantOperationID protocolsession.OperationID
Lane session.LaneIdentity
Disposition PeerAdmissionDisposition
Rejection protocolsession.LaneRejection
ResponseDelivery PeerResponseDelivery
LaneAttachment PeerLaneAttachment
}
PeerAdmissionResult is safe settlement evidence: it deliberately excludes WS2A/WS2B/WS2N bytes, nonces, proofs, traffic keys, and raw errors. The authenticated disposition remains authoritative when delivery or local attachment later fails.
type PeerHandler ¶
type PeerHandler interface {
protocolsession.MessageHandler
Cancel(context.Context, protocolsession.OperationID) error
Run(context.Context) error
}
PeerHandler owns provider policy, SDP/ICE interpretation, and physical PeerConnection lifetime outside core. Run must synchronously close all owned attempts before returning so ProtocolSession termination cannot leak peers.
type PeerHandlerFactory ¶
type PeerHandlerFactory interface {
protocolsession.OperationContinuationClassifier
NewSenderPeerHandler(PeerSession) (PeerHandler, error)
}
PeerHandlerFactory creates one isolated signaling owner per ProtocolSession. Implementations must not start asynchronous work before Run.
type PeerHandlerFactoryFunc ¶
type PeerHandlerFactoryFunc func(PeerSession) (PeerHandler, error)
func (PeerHandlerFactoryFunc) BeginOperationContinuation ¶
func (function PeerHandlerFactoryFunc) BeginOperationContinuation( protocolsession.MessageKind, []byte, ) (protocolsession.OperationContinuationContract, bool, error)
func (PeerHandlerFactoryFunc) ClassifyUnboundOperationContinuation ¶
func (function PeerHandlerFactoryFunc) ClassifyUnboundOperationContinuation( protocolsession.MessageKind, []byte, ) (protocolsession.OperationContinuationScope, bool, error)
func (PeerHandlerFactoryFunc) NewSenderPeerHandler ¶
func (function PeerHandlerFactoryFunc) NewSenderPeerHandler( peer PeerSession, ) (PeerHandler, error)
type PeerLaneAttachment ¶
type PeerLaneAttachment uint8
const ( PeerLaneAttachmentNotAttempted PeerLaneAttachment = iota + 1 PeerLaneAttached PeerLaneAttachmentFailed )
type PeerResponseDelivery ¶
type PeerResponseDelivery uint8
const ( PeerResponseNotAttempted PeerResponseDelivery = iota + 1 PeerResponseDelivered PeerResponseDeliveryFailed )
type PeerSession ¶
type PeerSession interface {
ProtocolSessionID() protocolsession.ProtocolSessionID
SendPeerControl(
context.Context,
protocolsession.MessageKind,
protocolsession.OperationID,
[]byte,
) (protocolsession.OperationDisposition, error)
FailPeerOperation(context.Context, protocolsession.OperationID, uint16, string) error
AdmitPeerChannel(
context.Context,
protocolsession.FrameChannel,
PeerAdmissionControl,
) (PeerAdmissionResult, error)
// Each control family owns an independent callback for the handler's Run
// lifetime. Passing nil removes only that family's callback.
SetPeerPathControlHandler(func(context.Context, []byte) error)
SendPeerPathControl(context.Context, []byte) error
SetTURNControlHandler(func(context.Context, []byte) error)
SendTURNControl(context.Context, []byte) error
}
PeerSession is the transport-neutral authority granted to one connectivity-owned peer handler. Operation-scoped signaling is restricted to answers and candidates. Session-scoped path and TURN controls are required so wrappers cannot silently disable path maintenance or TURN delegation. AdmitPeerChannel admits only into the ProtocolSession that created this authority and consumes the candidate channel: core closes it exactly once on failure, while successful attachment transfers close authority to the lane.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func (*Runtime) AdmitPeerChannel ¶
func (runtime *Runtime) AdmitPeerChannel( ctx context.Context, channel protocolsession.FrameChannel, control PeerAdmissionControl, ) (PeerAdmissionResult, error)
AdmitPeerChannel binds a connectivity-owned channel to this exact ProtocolSession before parsing its lane proof. A peer negotiation therefore cannot use the factory-wide untrusted route lookup to attach to a sibling receiver session.
func (*Runtime) AttachedLanes ¶
func (*Runtime) BeginClose ¶
func (runtime *Runtime) BeginClose()
func (*Runtime) DetachLane ¶
func (runtime *Runtime) DetachLane(identity session.LaneIdentity) bool
func (*Runtime) Err ¶
Only lifecycle observations and explicit control-handler installation cross the role boundary. The core's lane registry and operation ownership stay private.
func (*Runtime) LaneDone ¶
func (runtime *Runtime) LaneDone(identity session.LaneIdentity) (<-chan struct{}, bool)
LaneDone observes exact admitted ownership through registry release and transport cleanup. A remote close alone does not establish that boundary.
func (*Runtime) LaneIdentity ¶
func (*Runtime) LaneRegistry ¶
func (runtime *Runtime) LaneRegistry() *protocolsession.LaneRegistry
func (*Runtime) ProtocolSessionID ¶
func (runtime *Runtime) ProtocolSessionID() protocolsession.ProtocolSessionID
func (*Runtime) SetPeerPathControlHandler ¶
func (*Runtime) SetTURNControlHandler ¶
func (*Runtime) WaitClosed ¶
func (runtime *Runtime) WaitClosed()
type TerminalConnectivity ¶
type TerminalConnectivity interface {
// StopRecovery must return promptly after preventing new registration or
// path-recovery work. Existing lanes remain available for terminal delivery
// until Cleanup runs.
StopRecovery()
// Cleanup deregisters every relay route and closes connectivity-owned lanes.
Cleanup(context.Context) error
}
TerminalConnectivity is defined at the session consumer boundary. Core never learns provider, TURN, relay-node, or path-cost details; it only coordinates monotonic share termination with the owner of those resources.
type TerminalConnectivityFuncs ¶
type TerminalConnectivityFuncs struct {
StopRecoveryFunc func()
CleanupFunc func(context.Context) error
}
func (TerminalConnectivityFuncs) Cleanup ¶
func (functions TerminalConnectivityFuncs) Cleanup(ctx context.Context) error
func (TerminalConnectivityFuncs) StopRecovery ¶
func (functions TerminalConnectivityFuncs) StopRecovery()