Documentation
¶
Overview ¶
Package sessioncore owns encrypted lanes, exact-generation operation routing, and role-neutral session termination. Role packages supply control preparation and own role-specific diagnostic workers without sharing business services.
Index ¶
- Constants
- Variables
- func ConfirmChannelAdmission(ctx context.Context, channel protocolsession.FrameChannel) error
- func FinalizeLocalCancelIfDropped(runtime *Runtime, generation protocolsession.OperationGeneration, ...) error
- func ReadNonzeroLaneNonce(source io.Reader, size int) ([]byte, error)
- func ReceiveHandshake(ctx context.Context, receive <-chan framechannel.Frame) ([]byte, error)
- func RequestProvenNotDelivered(err error) bool
- func RevisionOperationCause(code uint16) (error, bool)
- type Call
- func (call *Call) BindOperationObserver(operation OperationObserver) error
- func (call *Call) ClaimProtocolTermination() *TerminalOwner
- func (call *Call) Close()
- func (call *Call) ContinuationLimit() (int, bool)
- func (call *Call) ID() protocolsession.OperationID
- func (call *Call) LastResponseLane() session.LaneIdentity
- func (call *Call) OperationAuthority() (protocolsession.OperationGeneration, protocolsession.OutboundOperationPermit)
- func (call *Call) RecordTraceCause(cause sessionobs.ProtocolOperationCause)
- func (call *Call) RecordTraceCleanup(err error)
- func (call *Call) RecordTraceFailure(err error)
- type Candidate
- type Component
- type Config
- type FailureSource
- type HandedOffChannel
- type LockedReader
- type OperationObserver
- type OperationOutcome
- type Requests
- func (client *Requests) Await(ctx context.Context, call *Call) (protocolsession.Message, error)
- func (client *Requests) AwaitCall(ctx context.Context, call *Call, cancelOnContext bool) (protocolsession.Message, error)
- func (client *Requests) AwaitPeer(ctx context.Context, call *Call) (protocolsession.Message, error)
- func (client *Requests) Begin(ctx context.Context, kind protocolsession.MessageKind, body []byte) (*Call, error)
- func (client *Requests) BeginCall(ctx context.Context, lane *session.LaneIdentity, call *Call, ...) error
- func (client *Requests) CancelAndEnd(call *Call, reason contentflow.CancelReason) error
- func (client *Requests) Close()
- func (client *Requests) End(call *Call)
- func (client *Requests) HandleMessage(ctx context.Context, message protocolsession.Message) error
- func (client *Requests) PrepareCall(ctx context.Context, kind protocolsession.MessageKind, body []byte) (*Call, protocolsession.Message, error)
- func (client *Requests) Register() error
- func (client *Requests) Runtime() *Runtime
- func (client *Requests) SendContinuation(ctx context.Context, call *Call, kind protocolsession.MessageKind, body []byte) (protocolsession.SendOutcome, error)
- type ResponseConfig
- type Responses
- func (outbound *Responses) SendControl(ctx context.Context, kind protocolsession.MessageKind, ...) (protocolsession.ResponseSendResult, error)
- func (outbound *Responses) SendFragment(ctx context.Context, message protocolsession.Message) error
- func (outbound *Responses) SendOperationError(ctx context.Context, operationID protocolsession.OperationID, ...) error
- func (outbound *Responses) SendSessionControl(ctx context.Context, kind protocolsession.MessageKind, body []byte) error
- func (outbound *Responses) SendTerminalAll(ctx context.Context, body []byte) error
- type Runtime
- func (runtime *Runtime) AbortBeforeStart()
- func (runtime *Runtime) AddFinalizer(finalize func()) error
- func (runtime *Runtime) AttachedLanes() int
- func (runtime *Runtime) BeginClose()
- func (runtime *Runtime) BeginExternalAdmission(ctx context.Context) (context.Context, func(), error)
- func (runtime *Runtime) CancelLifetime()
- func (runtime *Runtime) ClaimTermination(cause TerminationCause) TerminationClaim
- func (runtime *Runtime) ClassifyLaneWait(identity session.LaneIdentity, cause error) error
- func (runtime *Runtime) Close()
- func (runtime *Runtime) ConfigureLanes(queued func(session.LaneIdentity) time.Duration, ...)
- func (runtime *Runtime) DetachLane(identity session.LaneIdentity) bool
- func (runtime *Runtime) Done() <-chan struct{}
- func (runtime *Runtime) Err() error
- func (runtime *Runtime) Fail(err error)
- func (runtime *Runtime) FailOperationAuthority() error
- func (runtime *Runtime) FailProtocol(err error)
- func (runtime *Runtime) HasUsableLanes() bool
- func (runtime *Runtime) InstallLane(identity session.LaneIdentity, channel protocolsession.FrameChannel, ...) error
- func (runtime *Runtime) LaneDone(identity session.LaneIdentity) (<-chan struct{}, bool)
- func (runtime *Runtime) LaneIdentity() (uint32, uint32)
- func (runtime *Runtime) Lifetime() context.Context
- func (runtime *Runtime) NewLaneHello(grant protocolsession.LaneGrant) (protocolsession.LaneHello, error)
- func (runtime *Runtime) NewLaneNonce() ([]byte, error)
- func (runtime *Runtime) Now() time.Time
- func (runtime *Runtime) ObservationContext(id protocolsession.OperationID, kind protocolsession.MessageKind) sessionobs.ProtocolObservationContext
- func (runtime *Runtime) Observe(event sessionobs.ProtocolObservation)
- func (runtime *Runtime) PathsExhausted() bool
- func (runtime *Runtime) ProtocolSessionID() protocolsession.ProtocolSessionID
- func (runtime *Runtime) RecordError(err error)
- func (runtime *Runtime) RegisterHandler(kind protocolsession.MessageKind, handler protocolsession.MessageHandler) error
- func (runtime *Runtime) SendSessionControl(ctx context.Context, kind protocolsession.MessageKind, body []byte) error
- func (runtime *Runtime) SetPeerPathControlHandler(handler func(context.Context, []byte) error)
- func (runtime *Runtime) SetTURNControlHandler(handler func(context.Context, []byte) error)
- func (runtime *Runtime) ShareInstance() catalog.ShareInstance
- func (runtime *Runtime) Start(components ...Component)
- func (runtime *Runtime) Stopping() bool
- func (runtime *Runtime) TracingEnabled() bool
- func (runtime *Runtime) WaitClosed()
- type RuntimeLane
- type TerminalOwner
- type TerminalSendObservation
- type Termination
- type TerminationCause
- type TerminationClaim
- type TerminationObserver
- type TerminationObserverFunc
Constants ¶
const (
LaneGrantQueueLimit = 64
)
Variables ¶
var ( ErrLaneStale = errors.New("session runtime lane epoch is stale") )
var (
ErrOperationIDExhausted = errors.New("session runtime operation identity space is exhausted")
)
var ErrRequestCarrierRetired = fmt.Errorf("%w: request carrier retired before response", ErrLaneUnavailable)
Transport acceptance does not prove that a request or its final response reached the peer. The consumer must retire this attempt before retrying.
Functions ¶
func ConfirmChannelAdmission ¶
func ConfirmChannelAdmission(ctx context.Context, channel protocolsession.FrameChannel) error
func FinalizeLocalCancelIfDropped ¶
func FinalizeLocalCancelIfDropped( runtime *Runtime, generation protocolsession.OperationGeneration, outcome protocolsession.SendOutcome, ) error
func ReceiveHandshake ¶
func RevisionOperationCause ¶
Types ¶
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
func (*Call) BindOperationObserver ¶
func (call *Call) BindOperationObserver(operation OperationObserver) error
func (*Call) ClaimProtocolTermination ¶
func (call *Call) ClaimProtocolTermination() *TerminalOwner
func (*Call) ContinuationLimit ¶
func (*Call) ID ¶
func (call *Call) ID() protocolsession.OperationID
func (*Call) LastResponseLane ¶
func (call *Call) LastResponseLane() session.LaneIdentity
func (*Call) OperationAuthority ¶
func (call *Call) OperationAuthority() (protocolsession.OperationGeneration, protocolsession.OutboundOperationPermit)
func (*Call) RecordTraceCause ¶
func (call *Call) RecordTraceCause(cause sessionobs.ProtocolOperationCause)
func (*Call) RecordTraceCleanup ¶
func (*Call) RecordTraceFailure ¶
type Candidate ¶
type Candidate struct {
protocolsession.FrameChannel
// contains filtered or unexported fields
}
candidateChannelOwner makes the admission boundary consume one close authority. Failure paths and runtime lanes may converge on Close without calling provider cleanup more than once.
func NewCandidate ¶
func NewCandidate(channel protocolsession.FrameChannel) *Candidate
func NewCandidateWithReceive ¶
func NewCandidateWithReceive( channel protocolsession.FrameChannel, receive <-chan framechannel.Frame, ) *Candidate
func (*Candidate) ConfirmAdmission ¶
func (*Candidate) Recv ¶
func (owner *Candidate) Recv() <-chan framechannel.Frame
type Config ¶
type Config struct {
InitialRequestTiming *requestlane.Lane
Role protocolsession.Role
Keys protocolsession.SessionKeys
LaneID uint32
LaneEpoch uint32
Channel protocolsession.FrameChannel
Random io.Reader
Validator protocolsession.InboundMessageValidator
Continuations protocolsession.OperationContinuationClassifier
OperationLimits protocolsession.OperationLimits
RouterLimits protocolsession.RouterLimits
Now func() time.Time
ProtocolObservations observationstream.Producer[sessionobs.ProtocolObservation]
TerminationObserver TerminationObserver
}
type FailureSource ¶
type FailureSource string
const ( RuntimeFailureSourceContent FailureSource = "content" RuntimeFailureSourceCatalog FailureSource = "catalog" RuntimeFailureSourceLaneAdmission FailureSource = "lane_admission" RuntimeFailureSourcePeer FailureSource = "peer" )
type HandedOffChannel ¶
type HandedOffChannel struct {
protocolsession.FrameChannel
// contains filtered or unexported fields
}
func HandOff ¶
func HandOff(channel protocolsession.FrameChannel, receive <-chan framechannel.Frame) *HandedOffChannel
func (*HandedOffChannel) CapacityWait ¶
func (channel *HandedOffChannel) CapacityWait() time.Duration
func (*HandedOffChannel) Recv ¶
func (channel *HandedOffChannel) Recv() <-chan framechannel.Frame
type LockedReader ¶
type LockedReader struct {
// contains filtered or unexported fields
}
func NewLockedReader ¶
func NewLockedReader(reader io.Reader) *LockedReader
type OperationObserver ¶
type OperationObserver interface {
BindTerminalOwner(*TerminalOwner)
ObserveAuthenticatedOperationViolation(protocolsession.AuthenticatedOperationViolation)
}
OperationObserver is the consumer contract for a long-lived request owner. Binding happens before violation delivery; the adapter must only retain the terminal token and must not reenter the call while BindTerminalOwner runs.
type OperationOutcome ¶
type OperationOutcome struct {
Stage sessionobs.ProtocolOperationStage
Cause sessionobs.ProtocolOperationCause
}
type Requests ¶
type Requests struct {
// contains filtered or unexported fields
}
func (*Requests) Begin ¶
func (client *Requests) Begin(ctx context.Context, kind protocolsession.MessageKind, body []byte) (*Call, error)
func (*Requests) BeginCall ¶
func (client *Requests) BeginCall(ctx context.Context, lane *session.LaneIdentity, call *Call, message protocolsession.Message) error
func (*Requests) CancelAndEnd ¶
func (client *Requests) CancelAndEnd(call *Call, reason contentflow.CancelReason) error
func (*Requests) HandleMessage ¶
func (*Requests) PrepareCall ¶
func (client *Requests) PrepareCall(ctx context.Context, kind protocolsession.MessageKind, body []byte) (*Call, protocolsession.Message, error)
func (*Requests) SendContinuation ¶
func (client *Requests) SendContinuation(ctx context.Context, call *Call, kind protocolsession.MessageKind, body []byte) (protocolsession.SendOutcome, error)
type ResponseConfig ¶
type ResponseConfig struct {
Settlements observationstream.Producer[protocolsession.SendAttemptSettlement]
TerminalObserver func(TerminalSendObservation)
}
type Responses ¶
type Responses struct {
// contains filtered or unexported fields
}
func NewResponses ¶
func NewResponses(runtime *Runtime, config ResponseConfig) *Responses
func (*Responses) SendControl ¶
func (outbound *Responses) SendControl(ctx context.Context, kind protocolsession.MessageKind, operationID protocolsession.OperationID, body []byte) (protocolsession.ResponseSendResult, error)
func (*Responses) SendFragment ¶
func (*Responses) SendOperationError ¶
func (outbound *Responses) SendOperationError( ctx context.Context, operationID protocolsession.OperationID, failure contentflow.OperationFailure, ) error
func (*Responses) SendSessionControl ¶
func (outbound *Responses) SendSessionControl(ctx context.Context, kind protocolsession.MessageKind, body []byte) error
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func (*Runtime) AbortBeforeStart ¶
func (runtime *Runtime) AbortBeforeStart()
func (*Runtime) AddFinalizer ¶
func (*Runtime) AttachedLanes ¶
func (*Runtime) BeginClose ¶
func (runtime *Runtime) BeginClose()
func (*Runtime) BeginExternalAdmission ¶
func (*Runtime) CancelLifetime ¶
func (runtime *Runtime) CancelLifetime()
func (*Runtime) ClaimTermination ¶
func (runtime *Runtime) ClaimTermination(cause TerminationCause) TerminationClaim
func (*Runtime) ClassifyLaneWait ¶
func (runtime *Runtime) ClassifyLaneWait(identity session.LaneIdentity, cause error) error
ClassifyLaneWait is restricted to progress deadlines; ordinary failures retain their original semantics even when a relay has recently reported congestion.
func (*Runtime) ConfigureLanes ¶
func (runtime *Runtime) ConfigureLanes(queued func(session.LaneIdentity) time.Duration, detached func(session.LaneIdentity))
ConfigureLanes binds role dependencies before Start. Registry callbacks preserve runtime-lane then content-lane lock order and never transfer registry ownership.
func (*Runtime) DetachLane ¶
func (runtime *Runtime) DetachLane(identity session.LaneIdentity) bool
func (*Runtime) FailOperationAuthority ¶
func (*Runtime) FailProtocol ¶
func (*Runtime) HasUsableLanes ¶
func (*Runtime) InstallLane ¶
func (runtime *Runtime) InstallLane(identity session.LaneIdentity, channel protocolsession.FrameChannel, validator protocolsession.InboundMessageValidator, requests *requestlane.Lane, admit func() error) error
InstallLane publishes both protocol and role ownership under the same registry lock. A failed role admission cannot leave a protocol-only lane visible.
func (*Runtime) LaneDone ¶
func (runtime *Runtime) LaneDone(identity session.LaneIdentity) (<-chan struct{}, bool)
func (*Runtime) LaneIdentity ¶
func (*Runtime) Lifetime ¶
Lifetime cancels when session authority ends, before finalizers close Done. Dependent owners borrow it to stop waiting and revoke in-flight work while the runtime is still joining callbacks and physical resources.
func (*Runtime) NewLaneHello ¶
func (runtime *Runtime) NewLaneHello(grant protocolsession.LaneGrant) (protocolsession.LaneHello, error)
func (*Runtime) NewLaneNonce ¶
func (*Runtime) ObservationContext ¶
func (runtime *Runtime) ObservationContext(id protocolsession.OperationID, kind protocolsession.MessageKind) sessionobs.ProtocolObservationContext
func (*Runtime) Observe ¶
func (runtime *Runtime) Observe(event sessionobs.ProtocolObservation)
func (*Runtime) PathsExhausted ¶
func (*Runtime) ProtocolSessionID ¶
func (runtime *Runtime) ProtocolSessionID() protocolsession.ProtocolSessionID
func (*Runtime) RecordError ¶
func (*Runtime) RegisterHandler ¶
func (runtime *Runtime) RegisterHandler(kind protocolsession.MessageKind, handler protocolsession.MessageHandler) error
func (*Runtime) SendSessionControl ¶
func (runtime *Runtime) SendSessionControl(ctx context.Context, kind protocolsession.MessageKind, body []byte) error
func (*Runtime) SetPeerPathControlHandler ¶
func (*Runtime) SetTURNControlHandler ¶
func (*Runtime) ShareInstance ¶
func (runtime *Runtime) ShareInstance() catalog.ShareInstance
func (*Runtime) TracingEnabled ¶
func (*Runtime) WaitClosed ¶
func (runtime *Runtime) WaitClosed()
type RuntimeLane ¶
type RuntimeLane struct {
// contains filtered or unexported fields
}
type TerminalOwner ¶
type TerminalOwner struct {
// contains filtered or unexported fields
}
An owner holds terminal observation until its receive and cleanup results are known. Closing the RPC sink still wakes waiters immediately, but cannot publish a partial outcome that would hide a later joined fault.
func (*TerminalOwner) Finish ¶
func (owner *TerminalOwner) Finish(runtime *Runtime, outcome OperationOutcome)
type TerminalSendObservation ¶
type TerminalSendObservation struct {
ProtocolSessionID protocolsession.ProtocolSessionID
Lane session.LaneIdentity
Settled bool
Outcome protocolsession.SendOutcome
TransportDisposition framechannel.SendDisposition
NaturallyRetired bool
}
TerminalSendObservation carries only physical evidence, never operation or replay authority. Role observers cannot participate in send settlement.
type Termination ¶
type Termination struct {
ProtocolSessionID protocolsession.ProtocolSessionID
Cause TerminationCause
Failure diagnosticerror.Snapshot
}
Termination records the winning lifecycle cause independently of role-specific diagnostics. Later send or cleanup failures cannot rewrite this root.
type TerminationCause ¶
type TerminationCause uint8
const ( TerminationGracefulStop TerminationCause = iota + 1 TerminationForcedClose TerminationPeerTerminal TerminationPathsExhausted TerminationFailed )
type TerminationClaim ¶
type TerminationClaim struct {
// contains filtered or unexported fields
}
TerminationClaim retains the winner across an owner's lock boundary. Publishing is idempotent and bound to the originating runtime; a zero claim does nothing.
func (TerminationClaim) Publish ¶
func (claim TerminationClaim) Publish()
type TerminationObserver ¶
type TerminationObserver interface {
ObserveTermination(Termination)
}
type TerminationObserverFunc ¶
type TerminationObserverFunc func(Termination)
func (TerminationObserverFunc) ObserveTermination ¶
func (observe TerminationObserverFunc) ObserveTermination(event Termination)