receiversession

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 34 Imported by: 1 module, 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 receiversession owns download-side catalog, revision, block and peer operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrRemoteLeaseCollision = errors.New("sender reused an active lease identifier")
View Source
var ErrScanProgress = errors.New("session runtime scan progress changed identity or regressed")

Functions

This section is empty.

Types

type CatalogScanProgress

type CatalogScanProgress struct {
	DirectoryID       catalog.DirectoryID
	AttemptID         catalog.ScanAttemptID
	DiscoveredEntries uint64
}

type CatalogScanProgressObserver

type CatalogScanProgressObserver interface {
	ObserveCatalogScanProgress(context.Context, CatalogScanProgress) error
}

type CatalogScanProgressObserverFunc

type CatalogScanProgressObserverFunc func(context.Context, CatalogScanProgress) error

func (CatalogScanProgressObserverFunc) ObserveCatalogScanProgress

func (observe CatalogScanProgressObserverFunc) ObserveCatalogScanProgress(
	ctx context.Context,
	progress CatalogScanProgress,
) error

type Factory

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

func NewFactory

func NewFactory(config FactoryConfig) (*Factory, error)

func (*Factory) BeginClose

func (factory *Factory) BeginClose()

BeginClose seals the admission boundary before returning. Existing runtimes remain independent owners of their derived keys and resource leases.

func (*Factory) Close

func (factory *Factory) Close()

func (*Factory) Connect

func (factory *Factory) Connect(ctx context.Context, channel protocolsession.FrameChannel, route transferlanes.Route) (result *Runtime, resultErr error)

func (*Factory) WaitClosed

func (factory *Factory) WaitClosed()

type FactoryConfig

type FactoryConfig struct {
	ContentRoutePolicy                transferlanes.ContentRoutePolicy
	Descriptor                        catalog.ShareDescriptor
	SessionAuthKey                    []byte
	Sender                            *senderauth.Verifier
	CatalogVerifier                   catalogflow.ObjectVerifier
	RecordDecoder                     RecordDecoder
	ReassemblyProcess                 *contentflow.ReassemblyAccount
	ReassemblyShare                   *contentflow.ReassemblyAccount
	PlaintextProcess                  *transfer.PlaintextBudget
	Random                            io.Reader
	ReceiverInstances                 InstanceSource
	CatalogProgress                   CatalogScanProgressObserver
	PeerControls                      PeerSemantics
	RuntimeResources                  RuntimeResourceSource
	OperationLimits                   protocolsession.OperationLimits
	RouterLimits                      protocolsession.RouterLimits
	Now                               func() time.Time
	After                             func(time.Duration) <-chan time.Time
	ProtocolObservations              observationstream.Producer[sessionobs.ProtocolObservation]
	LaneSettlementObservationCapacity transferlanes.SettlementObservationCapacity
}

type InstanceSource

type InstanceSource interface {
	NewReceiverInstanceID() (protocolsession.ReceiverInstanceID, error)
}

type InstanceSourceFunc

type InstanceSourceFunc func() (protocolsession.ReceiverInstanceID, error)

func (InstanceSourceFunc) NewReceiverInstanceID

func (function InstanceSourceFunc) NewReceiverInstanceID() (protocolsession.ReceiverInstanceID, error)

type LaneAdmissionDisposition

type LaneAdmissionDisposition uint8
const (
	LaneAdmissionUnverified LaneAdmissionDisposition = iota + 1
	LaneAdmissionAccepted
	LaneAdmissionRejected
)

type LaneAdmissionResult

type LaneAdmissionResult struct {
	GrantOperationID protocolsession.OperationID
	Lane             session.LaneIdentity
	Disposition      LaneAdmissionDisposition
	Rejection        protocolsession.LaneRejection
	LaneInstallation LaneInstallation
}

LaneAdmissionResult separates authenticated sender settlement from local publication. A verified response remains authoritative even when the exact candidate owner cannot subsequently enter both receiver lane registries.

type LaneInstallation

type LaneInstallation uint8
const (
	LaneInstallationNotAttempted LaneInstallation = iota + 1
	LaneInstalled
	LaneInstallationFailed
)

type PeerControl

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

PeerControl is an authenticated sender signaling value. The runtime exposes semantic bytes only after the lane-bound signature and the injected peer schema validator have both succeeded.

func (PeerControl) Body

func (control PeerControl) Body() []byte

func (PeerControl) Kind

func (control PeerControl) Kind() protocolsession.MessageKind

type PeerDiagnostic

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

func (PeerDiagnostic) Code

func (diagnostic PeerDiagnostic) Code() PeerDiagnosticCode

func (PeerDiagnostic) RemoteFailure

func (diagnostic PeerDiagnostic) RemoteFailure() (
	RemoteOperationFailureSnapshot,
	bool,
)

type PeerDiagnosticCode

type PeerDiagnosticCode uint16
const (
	PeerDiagnosticOpaqueFailure PeerDiagnosticCode = iota + 1
	PeerDiagnosticContextCanceled
	PeerDiagnosticOperationMissing
	PeerDiagnosticRuntimeClosed
	PeerDiagnosticOperationOverflow
	PeerDiagnosticUnknownControl
	PeerDiagnosticControlMalformed
	PeerDiagnosticRemoteOperationRejected
	PeerDiagnosticRemoteFailureMalformed
	PeerDiagnosticRemoteFailureScopeViolation
	PeerDiagnosticRemoteAnswerConflict
	PeerDiagnosticRemoteFinalConflict
	PeerDiagnosticRemoteContinuationViolation
	PeerDiagnosticCleanupFailed
	PeerDiagnosticTruncated
)

type PeerDiagnosticSnapshot

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

func (PeerDiagnosticSnapshot) Components

func (snapshot PeerDiagnosticSnapshot) Components() []PeerDiagnostic

func (PeerDiagnosticSnapshot) Truncated

func (snapshot PeerDiagnosticSnapshot) Truncated() bool

type PeerOperation

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

PeerOperation owns one long-lived PEER_OFFER operation. Answer and candidates are fragments; a remote final, explicit Terminate, or runtime shutdown ends the exact operation object.

func (*PeerOperation) MaximumContinuations

func (operation *PeerOperation) MaximumContinuations() (int, bool)

func (*PeerOperation) OperationID

func (operation *PeerOperation) OperationID() protocolsession.OperationID

func (*PeerOperation) OwnsTermination

func (operation *PeerOperation) OwnsTermination(
	termination PeerTermination,
) bool

func (*PeerOperation) Receive

func (operation *PeerOperation) Receive(ctx context.Context) PeerReceiveResult

func (*PeerOperation) SendCandidate

func (operation *PeerOperation) SendCandidate(
	ctx context.Context,
	body []byte,
) (protocolsession.OperationDisposition, error)

func (*PeerOperation) Terminate

func (operation *PeerOperation) Terminate(ctx context.Context) PeerTermination

Terminate atomically claims local ownership when the exact operation is still active. If Receive or runtime shutdown already won, it joins that outcome instead. Every caller observes the same accumulated cause after in-flight Receive and exact-call cleanup complete.

type PeerReceiveResult

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

PeerReceiveResult is an immutable sum: invalid control/terminal combinations cannot be assembled with a public literal or mutable pointer.

func (PeerReceiveResult) Control

func (result PeerReceiveResult) Control() (PeerControl, bool)

func (PeerReceiveResult) Termination

func (result PeerReceiveResult) Termination() (PeerTermination, bool)

type PeerTerminalAuthority

type PeerTerminalAuthority uint8
const (
	PeerTerminalAuthorityLocal PeerTerminalAuthority
	PeerTerminalAuthorityRemote
	PeerTerminalAuthorityRuntime
)

type PeerTerminalProvenance

type PeerTerminalProvenance uint16
const (
	PeerProvenanceLocalExplicitStop PeerTerminalProvenance
	PeerProvenanceLocalContextEnded
	PeerProvenanceLocalOperationContract
	PeerProvenanceRemoteOperationRejected
	PeerProvenanceRemoteUnknownControl
	PeerProvenanceRemoteControlMalformed
	PeerProvenanceRemoteFailureMalformed
	PeerProvenanceRemoteFailureScopeViolation
	PeerProvenanceRemoteAnswerConflict
	PeerProvenanceRemoteFinalConflict
	PeerProvenanceRemoteContinuationViolation
	PeerProvenanceRuntimeStopping
	PeerProvenanceRemoteSessionRejected
)

type PeerTerminalSeverity

type PeerTerminalSeverity uint8
const (
	PeerTerminalOperationOnly PeerTerminalSeverity
	PeerTerminalSessionUnavailable
	PeerTerminalSessionUnsafe
)

type PeerTermination

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

PeerTermination is a sealed value. Diagnostics cannot manufacture authority, and a termination is valid only for the exact operation token that published it after receive and cleanup joined.

func (PeerTermination) Authority

func (termination PeerTermination) Authority() PeerTerminalAuthority

func (PeerTermination) ConsequenceProvenance

func (termination PeerTermination) ConsequenceProvenance() PeerTerminalProvenance

func (PeerTermination) Diagnostics

func (termination PeerTermination) Diagnostics() PeerDiagnosticSnapshot

func (PeerTermination) Severity

func (termination PeerTermination) Severity() PeerTerminalSeverity

func (PeerTermination) TransitionProvenance

func (termination PeerTermination) TransitionProvenance() PeerTerminalProvenance

type RecordDecoder added in v0.1.4

type RecordDecoder interface {
	DecodeRevision(catalog.FileID, uint32, []byte) (content.FileRevisionDescriptor, error)
	DecodeBlock(content.FileRevisionDescriptor, uint64, []byte) (records.BlockRecord, error)
}

type RemoteOperationError

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

func NewRemoteOperationError

func NewRemoteOperationError(failure RemoteOperationFailureSnapshot) RemoteOperationError

NewRemoteOperationError materializes an immutable diagnostic value from an already-owned snapshot. It carries no terminal authority; consumers obtain session consequences only from a sealed operation termination.

func (RemoteOperationError) Error

func (RemoteOperationError) Error() string

func (RemoteOperationError) Failure

type RemoteOperationFailureSnapshot

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

func (RemoteOperationFailureSnapshot) Code

func (failure RemoteOperationFailureSnapshot) Code() uint16

func (RemoteOperationFailureSnapshot) Message

func (failure RemoteOperationFailureSnapshot) Message() string

func (RemoteOperationFailureSnapshot) RetryAfter

func (failure RemoteOperationFailureSnapshot) RetryAfter() time.Duration

func (RemoteOperationFailureSnapshot) Retryable

func (failure RemoteOperationFailureSnapshot) Retryable() bool

func (RemoteOperationFailureSnapshot) Scope

func (failure RemoteOperationFailureSnapshot) Scope() uint8

type RemoteRevisionError

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

RemoteRevisionError retains the authenticated OPEN_RESULTS diagnostic without letting observers mutate the semantic authority already assigned to the job.

func (*RemoteRevisionError) Error

func (err *RemoteRevisionError) Error() string

func (*RemoteRevisionError) Failure

func (*RemoteRevisionError) OperationID

func (err *RemoteRevisionError) OperationID() protocolsession.OperationID

func (*RemoteRevisionError) ProtocolSessionID

func (err *RemoteRevisionError) ProtocolSessionID() protocolsession.ProtocolSessionID

type Runtime

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

func (*Runtime) AttachLane

AttachLane consumes one connectivity-owned candidate channel. Core closes that owner on every failure; successful installation transfers it to the runtime lane that will close it on exact detachment or session termination.

func (*Runtime) AttachedLanes

func (runtime *Runtime) AttachedLanes() int

func (*Runtime) AwaitPathRetirement

func (runtime *Runtime) AwaitPathRetirement(ctx context.Context) bool

AwaitPathRetirement joins the physical lane owners before inspecting their winning termination. A request can observe no usable lane while its pump is still retiring; that scheduling race must not discard valid output progress.

func (*Runtime) BeginClose

func (runtime *Runtime) BeginClose()

func (*Runtime) BindDownloadMetrics

func (runtime *Runtime) BindDownloadMetrics(metrics *downloadmetrics.Metrics)

BindDownloadMetrics binds one generation's availability and delivery producers to the same download observation without sharing their synchronization state.

func (*Runtime) BlockBroker

func (runtime *Runtime) BlockBroker() *transfer.BlockBroker

func (*Runtime) Catalog

func (runtime *Runtime) Catalog() *catalogflow.Client

func (*Runtime) CleanupError

func (runtime *Runtime) CleanupError() error

CleanupError is final after Done closes. It preserves resource-settlement failures independently of the protocol cause that originally stopped a session.

func (*Runtime) Close

func (runtime *Runtime) Close()

func (*Runtime) Descriptor

func (runtime *Runtime) Descriptor() catalog.ShareDescriptor

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

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 identifies exact admitted ownership without consuming transport frames. Connectivity can recover one retired relay while other lanes remain.

func (*Runtime) LaneIdentity

func (runtime *Runtime) LaneIdentity() (uint32, uint32)

func (*Runtime) LaneSet

func (runtime *Runtime) LaneSet() *transferlanes.Set

func (*Runtime) Lifetime

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

func (*Runtime) NewTransferJob

NewTransferJob binds one confirmed receive intent to a single transfer run. The materializer may reopen durable state, but the live protocol session can never derive OperationID from its per-run TransferJobID.

func (*Runtime) OpenPeerOperation

func (runtime *Runtime) OpenPeerOperation(
	ctx context.Context,
	offer []byte,
) (*PeerOperation, error)

func (*Runtime) OpenRevision

func (runtime *Runtime) OpenRevision(
	ctx context.Context,
	file catalog.FileID,
) (revisionaccess.Lease, error)

func (*Runtime) PathRecoveryFailure

func (runtime *Runtime) PathRecoveryFailure(cause error) error

PathRecoveryFailure preserves the network root after an external replacement budget or handshake fails. Child timeout diagnostics are not caller cancellation.

func (*Runtime) PathsExhausted

func (runtime *Runtime) PathsExhausted() bool

PathsExhausted reports the winning lifecycle authority, never an error-text classification. Protocol failures and caller cleanup cannot authorize recovery.

func (*Runtime) ProtocolSessionID

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

func (*Runtime) RejectShareIdentity

func (runtime *Runtime) RejectShareIdentity(cause error)

RejectShareIdentity ends authority after the application authenticates a contradictory share descriptor. It cannot authorize path recovery, and keeps the protocol cause distinct from the component cancellation used for cleanup.

func (*Runtime) ReleaseRevision

func (runtime *Runtime) ReleaseRevision(ctx context.Context, lease content.LeaseID) error

func (*Runtime) RequestLane

func (runtime *Runtime) RequestLane(
	ctx context.Context,
	requestedLaneID uint32,
) (protocolsession.LaneGrant, error)

RequestLane obtains the one-use sender-signed grant before connectivity opens or attaches a new physical channel.

func (*Runtime) ResolveOrdinaryOutputShape

func (runtime *Runtime) ResolveOrdinaryOutputShape(
	ctx context.Context,
	selection transfer.SelectionSpec,
	budget ordinaryoutput.ShapeProbeBudget,
	tracer ordinaryoutput.ShapeTracer,
) (ordinaryoutput.ShapeDecision, error)

ResolveOrdinaryOutputShape consumes only authenticated catalog metadata from this live session. The returned proof is construction-time state and cannot outlive the canonical ReceiveIntent assembled by its caller.

func (*Runtime) SendPeerPathControl

func (runtime *Runtime) SendPeerPathControl(ctx context.Context, body []byte) error

func (*Runtime) SendTURNControl

func (runtime *Runtime) SendTURNControl(ctx context.Context, 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) Stopping

func (runtime *Runtime) Stopping() bool

func (*Runtime) TransferDependencies

func (runtime *Runtime) TransferDependencies() (TransferDependencies, error)

TransferDependencies exposes protocol operations without giving a transfer owner access to the runtime's crypto, grants, or lease registry.

func (*Runtime) WaitClosed

func (runtime *Runtime) WaitClosed()

type RuntimeResourceLease

type RuntimeResourceLease interface {
	Release()
}

type RuntimeResourceSource

type RuntimeResourceSource interface {
	AcquireReceiverRuntimeResources() (RuntimeResourceLease, error)
}

type TransferDependencies

type TransferDependencies = receiverTransferDependencies

Jump to

Keyboard shortcuts

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