sessioncore

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	LaneGrantQueueLimit = 64
)

Variables

View Source
var (
	ErrLaneUnavailable = errors.New("session runtime has no usable lane")
	ErrLaneStale       = errors.New("session runtime lane epoch is stale")
)
View Source
var (
	ErrOperationIDExhausted = errors.New("session runtime operation identity space is exhausted")
)
View Source
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 ReadNonzeroLaneNonce

func ReadNonzeroLaneNonce(source io.Reader, size int) ([]byte, error)

func ReceiveHandshake

func ReceiveHandshake(ctx context.Context, receive <-chan framechannel.Frame) ([]byte, error)

func RequestProvenNotDelivered

func RequestProvenNotDelivered(err error) bool

func RevisionOperationCause

func RevisionOperationCause(code uint16) (error, bool)

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) Close

func (call *Call) Close()

func (*Call) ContinuationLimit

func (call *Call) ContinuationLimit() (int, bool)

func (*Call) ID

func (call *Call) ID() protocolsession.OperationID

func (*Call) LastResponseLane

func (call *Call) LastResponseLane() session.LaneIdentity

func (*Call) RecordTraceCause

func (call *Call) RecordTraceCause(cause sessionobs.ProtocolOperationCause)

func (*Call) RecordTraceCleanup

func (call *Call) RecordTraceCleanup(err error)

func (*Call) RecordTraceFailure

func (call *Call) RecordTraceFailure(err error)

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) Close

func (owner *Candidate) Close() error

func (*Candidate) ConfirmAdmission

func (owner *Candidate) ConfirmAdmission(ctx context.Context) error

func (*Candidate) Recv

func (owner *Candidate) Recv() <-chan framechannel.Frame

type Component

type Component struct {
	Source FailureSource
	Run    func(context.Context) error
}

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

func (*LockedReader) Read

func (reader *LockedReader) Read(destination []byte) (int, error)

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 NewRequests

func NewRequests(runtime *Runtime, random io.Reader) *Requests

func (*Requests) Await

func (client *Requests) Await(ctx context.Context, call *Call) (protocolsession.Message, error)

func (*Requests) AwaitCall

func (client *Requests) AwaitCall(ctx context.Context, call *Call, cancelOnContext bool) (protocolsession.Message, error)

func (*Requests) AwaitPeer

func (client *Requests) AwaitPeer(ctx context.Context, call *Call) (protocolsession.Message, error)

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) Close

func (client *Requests) Close()

func (*Requests) End

func (client *Requests) End(call *Call)

func (*Requests) HandleMessage

func (client *Requests) HandleMessage(ctx context.Context, message protocolsession.Message) error

func (*Requests) PrepareCall

func (client *Requests) PrepareCall(ctx context.Context, kind protocolsession.MessageKind, body []byte) (*Call, protocolsession.Message, error)

func (*Requests) Register

func (client *Requests) Register() error

func (*Requests) Runtime

func (client *Requests) Runtime() *Runtime

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 {
	ControlPreparer  SenderControlPreparer
	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 (*Responses) SendFragment

func (outbound *Responses) SendFragment(ctx context.Context, message protocolsession.Message) error

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

func (*Responses) SendTerminalAll

func (outbound *Responses) SendTerminalAll(ctx context.Context, body []byte) error

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Runtime, error)

func (*Runtime) AbortBeforeStart

func (runtime *Runtime) AbortBeforeStart()

func (*Runtime) AddFinalizer

func (runtime *Runtime) AddFinalizer(finalize func()) error

func (*Runtime) AttachedLanes

func (runtime *Runtime) AttachedLanes() int

func (*Runtime) BeginClose

func (runtime *Runtime) BeginClose()

func (*Runtime) BeginExternalAdmission

func (runtime *Runtime) BeginExternalAdmission(ctx context.Context) (context.Context, func(), error)

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) Close

func (runtime *Runtime) Close()

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) Done

func (runtime *Runtime) Done() <-chan struct{}

func (*Runtime) Err

func (runtime *Runtime) Err() error

func (*Runtime) Fail

func (runtime *Runtime) Fail(err error)

func (*Runtime) FailOperationAuthority

func (runtime *Runtime) FailOperationAuthority() error

func (*Runtime) FailProtocol

func (runtime *Runtime) FailProtocol(err error)

func (*Runtime) HasUsableLanes

func (runtime *Runtime) HasUsableLanes() bool

func (*Runtime) InstallLane

func (runtime *Runtime) InstallLane(identity session.LaneIdentity, channel protocolsession.FrameChannel, authenticator protocolsession.InboundMessageAuthenticator, 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 *Runtime) LaneIdentity() (uint32, uint32)

func (*Runtime) Lifetime

func (runtime *Runtime) Lifetime() context.Context

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 *Runtime) NewLaneNonce() ([]byte, error)

func (*Runtime) Now

func (runtime *Runtime) Now() time.Time

func (*Runtime) Observe

func (runtime *Runtime) Observe(event sessionobs.ProtocolObservation)

func (*Runtime) PathsExhausted

func (runtime *Runtime) PathsExhausted() bool

func (*Runtime) ProtocolSessionID

func (runtime *Runtime) ProtocolSessionID() protocolsession.ProtocolSessionID

func (*Runtime) RecordError

func (runtime *Runtime) RecordError(err error)

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 *Runtime) SetPeerPathControlHandler(handler func(context.Context, []byte) error)

func (*Runtime) SetTURNControlHandler

func (runtime *Runtime) SetTURNControlHandler(handler func(context.Context, []byte) error)

func (*Runtime) ShareInstance

func (runtime *Runtime) ShareInstance() catalog.ShareInstance

func (*Runtime) Start

func (runtime *Runtime) Start(components ...Component)

func (*Runtime) Stopping

func (runtime *Runtime) Stopping() bool

func (*Runtime) TracingEnabled

func (runtime *Runtime) TracingEnabled() bool

func (*Runtime) WaitClosed

func (runtime *Runtime) WaitClosed()

type RuntimeLane

type RuntimeLane struct {
	// contains filtered or unexported fields
}

type SenderControlPreparer

SenderControlPreparer supplies signing authority without transferring key ownership to the shared runtime. The writer still chooses the sealed sequence.

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL