receive

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 38 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 receive owns one receive operation across connection generations.

Index

Constants

View Source
const (
	OutputLookupCreateReady    = output.OutputLookupCreateReady
	OutputLookupNotFound       = output.OutputLookupNotFound
	OutputLookupReopened       = output.OutputLookupReopened
	OutputLookupAlreadyRunning = output.OutputLookupAlreadyRunning
	OutputLookupNeedsAttention = output.OutputLookupNeedsAttention
	OutputLookupAmbiguous      = output.OutputLookupAmbiguous
)
View Source
const (
	PeerFallbackAllowed    = receiverPeerFallbackAllowed
	PeerSessionUnavailable = receiverPeerSessionUnavailable
	PeerSessionUnsafe      = receiverPeerSessionUnsafe
	PeerLocalStop          = receiverPeerLocalStop
)
View Source
const MaxNameAdjustmentSamples = output.MaxNameAdjustmentSamples

Variables

View Source
var ErrInvalidConnectivityPolicy = errors.New("invalid connectivity policy")
View Source
var (
	ErrInvalidReceiverAdmission = errors.New("receiver content admission signal is invalid")
)
View Source
var ErrInvalidResult = errors.New("receive result violates its settlement contract")
View Source
var ErrMissingOutputFactory = errors.New("receive output factory is required")
View Source
var (
	ErrRetainedOutputMissing = errors.New("no retained download matches this link and selection")
)

Functions

func Run

func Run(ctx context.Context, request Request, deps Dependencies) task.Completion[Result]

func Settle

func Settle(input SettlementInput) (task.Completion[Result], error)

Types

type AdmissionObserved

type AdmissionObserved struct {
	Operation     receivecontract.OperationID
	Job           transfer.TransferJobID
	Session       protocolsession.ProtocolSessionID
	Trigger       AdmissionTrigger
	TerminalOwner AdmissionTerminalOwner
	Cause         error
	// contains filtered or unexported fields
}

func (AdmissionObserved) DiagnosticRecord

func (v AdmissionObserved) DiagnosticRecord() diagnostics.Record

func (AdmissionObserved) EngineEvent

func (AdmissionObserved) EngineEvent()

type AdmissionTerminalOwner

type AdmissionTerminalOwner = receiverAdmissionTerminalOwner

type AdmissionTrigger

type AdmissionTrigger = receiverAdmissionTrigger

type Clock

type Clock interface {
	Now() time.Time
	NewTicker(time.Duration) Ticker
}

type ConnectivityPolicy

type ConnectivityPolicy uint8

ConnectivityPolicy owns both peer-attempt requirements and application-relay content admission. Keeping those decisions together prevents a mode from accidentally admitting the content path it promises to exclude.

const (
	ConnectivityAuto ConnectivityPolicy = iota + 1
	ConnectivityRelayOnly
	ConnectivityP2POnly
)

func ParseConnectivityPolicy

func ParseConnectivityPolicy(value string) (ConnectivityPolicy, error)

func (ConnectivityPolicy) String

func (policy ConnectivityPolicy) String() string

type ContentPath

type ContentPath uint8
const (
	ContentPathRelay ContentPath = iota + 1
	ContentPathDirect
	ContentPathDirectAndRelay
)

type ContentPathObserved

type ContentPathObserved struct {
	Path ContentPath
	// contains filtered or unexported fields
}

func (ContentPathObserved) EngineEvent

func (ContentPathObserved) EngineEvent()

type Dependencies

type Dependencies struct {
	Capacity         *liveshare.ReceiveCapacity
	Connectivity     *nativeconnectivity.Capacity
	ICEPool          func() icepolicy.ICEEndpointPool
	SleepInhibitor   SleepInhibitor
	Control          task.Control
	Clock            Clock
	ReceiverDial     func(context.Context, relayv2.ReceiverConfig) (relayset.ReceiverConnection, error)
	Recovery         relayset.ReceiverRecoveryOptions
	PeerFactory      func() (PeerStarter, error)
	ResolveEndpoints func(context.Context) ([]string, error)
}

type Failure

type Failure struct {
	Fault        transferfault.Fault
	Interruption transfer.TransferInterruption
	Local        LocalFailure
	Code         FailureCode
	Cause        error
}

Failure retains the authoritative reason selected by application precedence. Clients translate these domain values to vocabulary without re-deciding it.

func (Failure) Error

func (failure Failure) Error() string

func (Failure) Unwrap

func (failure Failure) Unwrap() error

type FailureCode

type FailureCode uint8
const (
	FailureInvalidInput FailureCode = iota + 1
	FailureOutputContract
	FailureOutputOperationAlreadyRunning
	FailureOutputNeedsAttention
	FailureOutputOwnership
	FailureRetainedOutputMissing
	FailurePeerConfiguration
	FailurePeerNegotiation
	FailurePeerProtocol
	FailurePeerSignaling
	FailurePeerStopped
	FailureShareStopped
)

type FallbackObserved

type FallbackObserved struct {
	Code FailureCode
	// contains filtered or unexported fields
}

func (FallbackObserved) EngineEvent

func (FallbackObserved) EngineEvent()

type GenerationChanged

type GenerationChanged struct {
	Operation         receivecontract.OperationID
	Job               transfer.TransferJobID
	Previous, Current protocolsession.ProtocolSessionID
	// contains filtered or unexported fields
}

func (GenerationChanged) DiagnosticRecord

func (v GenerationChanged) DiagnosticRecord() diagnostics.Record

func (GenerationChanged) EngineEvent

func (GenerationChanged) EngineEvent()

type LaneAdopted

type LaneAdopted struct {
	Session protocolsession.ProtocolSessionID
	Lane    session.LaneIdentity
	// contains filtered or unexported fields
}

func (LaneAdopted) EngineEvent

func (LaneAdopted) EngineEvent()

type LocalFailure

type LocalFailure uint8
const (
	LocalFailureNone LocalFailure = iota
	LocalSelectionMissing
	LocalRevisionConflict
	LocalCheckpointInvalid
	LocalOwnedObjectUnknown
	LocalDestinationCollision
	LocalSourceOmitted
)

type NameAdjustment added in v0.1.6

type NameAdjustment = output.NameAdjustment

type NameAdjustmentSummary added in v0.1.6

type NameAdjustmentSummary = output.NameAdjustmentSummary

type ObservationSource

type ObservationSource string
const (
	ObservationRelay ObservationSource = "relay"

	ObservationWebRTC ObservationSource = "webrtc"

	ObservationLane ObservationSource = "lane"

	ObservationNative ObservationSource = "native"

	ObservationProtocol ObservationSource = "protocol"

	ObservationPeerTermination ObservationSource = "peer_termination"

	ObservationPeerDiagnostic ObservationSource = "peer_diagnostic"
)

type OutputAdmission

type OutputAdmission uint8

Request binds one destination authority to a selection. Reconnection never reacquires it: its reservation and authenticated progress belong to the task.

const (
	OutputCreateOrResume OutputAdmission = iota
	OutputResumeExisting
	OutputRedownload
)

type OutputAuthority

type OutputAuthority = output.Authority

type OutputConfig

type OutputConfig = output.Config

type OutputFactory

type OutputFactory = output.Factory

type OutputFactoryFunc

type OutputFactoryFunc = output.FactoryFunc

type OutputLookup

type OutputLookup = output.Lookup

type OutputLookupKind

type OutputLookupKind = output.LookupKind

type OutputOperation

type OutputOperation = output.Operation

type OutputReservation

type OutputReservation = output.Reservation

type Pause

type Pause struct {
	Operation receivecontract.OperationID
	Recovery  RecoveryOutcome
	Actions   []RecoveryAction
	Transfer  transfer.JobResult
}

Pause is a settled attempt while the operation still owns its output. The decision port is optional; unattended callers always get an explicit result.

func (Pause) Allows

func (pause Pause) Allows(action RecoveryAction) bool

type PeerAttempt

type PeerAttempt = receiverPeerAttempt

type PeerDisposition

type PeerDisposition = receiverPeerDisposition

type PeerOutcome

type PeerOutcome = receiverPeerMonitorOutcome

func NewPeerOutcome

func NewPeerOutcome(disposition PeerDisposition, cause error) PeerOutcome

type PeerStarter

type PeerStarter = receiverPeerStarter

Aliases expose only the caller-owned injection seams, not lifecycle helpers.

type PeerTerminated

type PeerTerminated struct {
	Value     v2peer.ReceiverTerminationTrace
	LocalStop ReceiverLocalStopReason
	// contains filtered or unexported fields
}

func (PeerTerminated) EngineEvent

func (PeerTerminated) EngineEvent()

type ProgressObserved

type ProgressObserved struct {
	Operation    receivecontract.OperationID
	Job          transfer.TransferJobID
	Value        transfer.ReceiveProgressSnapshot
	Connectivity downloadmetrics.Snapshot
	// contains filtered or unexported fields
}

func (ProgressObserved) EngineEvent

func (ProgressObserved) EngineEvent()

type ProgressRetention

type ProgressRetention uint8
const (
	RetentionNone ProgressRetention = iota
	RetentionCheckpoints
	RetentionDiscarded
)

type ReceiverLocalStopReason

type ReceiverLocalStopReason uint8
const (
	ReceiverLocalStopNone ReceiverLocalStopReason = iota + 1
	ReceiverLocalStopCaller
	ReceiverLocalStopOutputAdmission
	ReceiverLocalStopRuntimeSessionFailure
	ReceiverLocalStopNormalCompletion
)

func (ReceiverLocalStopReason) DiagnosticName

func (v ReceiverLocalStopReason) DiagnosticName() string

type RecoveryAction

type RecoveryAction uint8
const (
	RecoveryExit RecoveryAction = iota + 1
	RecoveryRetry
	RecoveryDiscard
)

type RecoveryObserved

type RecoveryObserved struct {
	Value relayset.ReceiverRecoveryObservation
	// contains filtered or unexported fields
}

func (RecoveryObserved) EngineEvent

func (RecoveryObserved) EngineEvent()

type RecoveryOutcome

type RecoveryOutcome struct {
	Retention ProgressRetention
	Reason    RecoveryReason
	ShareStop ShareStopSource
}

Retention is independent of the next step: an invalid selection can coexist with completed files and reusable partials that must remain owned and intact.

func (RecoveryOutcome) Retryable added in v0.1.5

func (outcome RecoveryOutcome) Retryable() bool

Retryable describes replaying the same request after any local remediation. Link viability and the primary fault are independent of output ownership.

func (RecoveryOutcome) ShareStopped added in v0.1.5

func (outcome RecoveryOutcome) ShareStopped() bool

type RecoveryReason

type RecoveryReason uint8
const (
	RecoveryTransferFailure RecoveryReason = iota + 1
	RecoveryCollision
	RecoveryOwnershipUnknown
	RecoveryRevisionChanged
	RecoverySelectionMissing
	RecoverySourceOmitted
	RecoveryInvalidRequest
	RecoveryNeedsInspection
)

type RelayConnected

type RelayConnected struct {
	Endpoint v2.RelayEndpoint
	// contains filtered or unexported fields
}

func (RelayConnected) EngineEvent

func (RelayConnected) EngineEvent()

type RelayContentClaimed

type RelayContentClaimed struct {
	Operation receivecontract.OperationID
	Job       transfer.TransferJobID
	Session   protocolsession.ProtocolSessionID
	Trigger   AdmissionTrigger
	// contains filtered or unexported fields
}

RelayContentClaimed records ownership of an admission attempt, before resume. Completion and useful byte delivery are independent observations.

func (RelayContentClaimed) DiagnosticRecord

func (v RelayContentClaimed) DiagnosticRecord() diagnostics.Record

func (RelayContentClaimed) EngineEvent

func (RelayContentClaimed) EngineEvent()

type Request

type Request struct {
	Admission    OutputAdmission
	OperationID  receivecontract.OperationID
	Capability   link.Link
	Only         []string
	Connectivity ConnectivityPolicy
	WaitTimeout  time.Duration
	Output       OutputFactory
	Destination  string
	Diagnostics  diagnostics.Sink
	OnPause      func(context.Context, Pause) (RecoveryAction, error)
}

type Result

type Result struct {
	OutputAttention     recovery.AttentionReason
	Recovery            RecoveryOutcome
	Transfer            transfer.JobResult
	Operation           receivecontract.OperationID
	Job                 transfer.TransferJobID
	Destination         string
	DestinationAdjusted bool
	NameAdjustments     output.NameAdjustmentSummary
	Elapsed             time.Duration
	Connectivity        downloadmetrics.Snapshot
}

type SettlementInput

type SettlementInput struct {
	Result                                                                    transfer.JobResult
	AdmissionError, RuntimeError, ConnectionError, ContextError, CleanupError error
	Elapsed                                                                   time.Duration
	Destination                                                               string
	DestinationAdjusted                                                       bool
	NameAdjustments                                                           output.NameAdjustmentSummary
	Operation                                                                 receivecontract.OperationID
	Job                                                                       transfer.TransferJobID
	Connectivity                                                              downloadmetrics.Snapshot
}

type ShareStopSource added in v0.1.5

type ShareStopSource uint8
const (
	ShareStopUnconfirmed ShareStopSource = iota
	ShareStopSender
	ShareStopRelays
	ShareStopRecorded
)

func (ShareStopSource) String added in v0.1.5

func (source ShareStopSource) String() string

type SleepInhibitor added in v0.1.6

type SleepInhibitor interface {
	InhibitSleep(reason string) (release func(), err error)
}

SleepInhibitor keeps the host awake while an active receive transfer runs.

type Ticker

type Ticker interface {
	C() <-chan time.Time
	Stop()
}

type Warning

type Warning struct {
	Code  FailureCode
	Cause error
	// contains filtered or unexported fields
}

func (Warning) EngineEvent

func (Warning) EngineEvent()

Jump to

Keyboard shortcuts

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