relayset

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 Imports: 22 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 relayset coordinates independent relay endpoint lifecycles. Each endpoint retains registration/resume authority; the set only merges ingress.

Index

Constants

View Source
const MaximumEndpoints = 8
View Source
const (
	ReceiverInitialWait = 10 * time.Second
)

Variables

View Source
var (
	ErrReceiverUnavailable  = errors.New("share is temporarily unavailable")
	ErrReceiverWaitExpired  = errors.New("receiver connection waiting deadline expired")
	ErrReceiverShareChanged = errors.New("receiver authenticated share descriptor changed")
)
View Source
var ErrConfig = errors.New("invalid sender relay set configuration")
View Source
var ErrReceiverAuthentication = errors.New("receiver relay authentication failed")

Functions

This section is empty.

Types

type Admission

type Admission struct {
	Endpoint, Primary, State string
	Count                    int
}

type NetworkAdmissions

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

NetworkAdmissions coordinates only directory candidates. Configured endpoints keep independent lifetimes, and no successful published connection is evicted.

func NewNetworkAdmissions

func NewNetworkAdmissions(plan relayplan.Plan) *NetworkAdmissions

func (*NetworkAdmissions) Control

func (*NetworkAdmissions) Observe

func (a *NetworkAdmissions) Observe(observer func(Admission))

type Receiver

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

Receiver owns relay connections for one cryptographic session. Competing initial handshakes race to publish the first usable session; losers release their authority and join the winner using a fresh authenticated lane grant.

func NewReceiver

func NewReceiver(ctx context.Context, config ReceiverConfig) (*Receiver, error)

func (*Receiver) Close

func (receiver *Receiver) Close()

func (*Receiver) WaitReady

func (receiver *Receiver) WaitReady(ctx context.Context) (*receiversession.Runtime, ReceiverConnection, error)

type ReceiverClock

type ReceiverClock interface {
	Now() time.Time
	Wait(context.Context, time.Duration) error
}

type ReceiverConfig

type ReceiverConfig struct {
	Clock            ReceiverClock
	Receiver         liveshare.ReceiverConfig
	Dial             func(context.Context, relayv2.ReceiverConfig) (ReceiverConnection, error)
	DialOptions      relayv2.DialOptions
	Connected        func(ReceiverConnection)
	ResolveEndpoints func(context.Context) ([]string, error)
	// contains filtered or unexported fields
}

type ReceiverConnection

type ReceiverConnection interface {
	Descriptor() []byte
	Channel() protocolsession.FrameChannel
	Endpoint() v2.RelayEndpoint
	Done() <-chan struct{}
	Err() error
	Close() error
}

ReceiverConnection is the authority needed to attach and retire one relay lane.

func DialReceiver

func DialReceiver(ctx context.Context, config relayv2.ReceiverConfig) (ReceiverConnection, error)

type ReceiverJoinFailure

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

ReceiverJoinFailure retains endpoint authority boundaries. One permanently rejected endpoint cannot veto recovery through an independently failed relay.

func (*ReceiverJoinFailure) Error

func (failure *ReceiverJoinFailure) Error() string

func (*ReceiverJoinFailure) RetryEndpoints

func (failure *ReceiverJoinFailure) RetryEndpoints() []string

func (*ReceiverJoinFailure) Unwrap

func (failure *ReceiverJoinFailure) Unwrap() []error

type ReceiverRecovery

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

func NewReceiverRecovery

func NewReceiverRecovery(options ReceiverRecoveryOptions) (*ReceiverRecovery, error)

func (*ReceiverRecovery) Join

func (recovery *ReceiverRecovery) Join(ctx context.Context, config ReceiverConfig) (*Receiver, error)

Join has a finite default window. An explicit caller wait limit also selects how long the caller wants to wait before any usable share has been observed.

func (*ReceiverRecovery) Replace

func (recovery *ReceiverRecovery) Replace(ctx context.Context, config ReceiverConfig) (*Receiver, error)

Replace waits through temporary outages until success, terminal rejection, or caller cancellation. The unchanged continuation owns the transfer and output.

type ReceiverRecoveryObservation

type ReceiverRecoveryObservation struct {
	Endpoint             string
	Attempt              uint32
	Phase                ReceiverRecoveryPhase
	Delay                time.Duration
	ProtocolSessionID    [16]byte
	ConnectionGeneration uint64
	Err                  error
}

type ReceiverRecoveryOptions

type ReceiverRecoveryOptions struct {
	Clock          ReceiverClock
	TimeoutContext func(context.Context, time.Duration) (context.Context, context.CancelFunc)
	InitialWait    time.Duration
	FastWindow     time.Duration
	WaitTimeout    time.Duration
	Jitter         func(time.Duration) time.Duration
	Observe        func(ReceiverRecoveryObservation)
}

A joined share keeps endpoint decisions and retry pressure across protocol generations. Neither a new session nor a lane attachment resets this owner.

type ReceiverRecoveryPhase

type ReceiverRecoveryPhase string
const (
	ReceiverRecoveryConnecting ReceiverRecoveryPhase = "connecting"
	ReceiverRecoveryRetrying   ReceiverRecoveryPhase = "retrying"
	ReceiverRecoveryWaiting    ReceiverRecoveryPhase = "waiting"
	ReceiverRecoveryConnected  ReceiverRecoveryPhase = "connected"
	ReceiverRecoveryTerminal   ReceiverRecoveryPhase = "terminal"
)

type RegistrationFailure

type RegistrationFailure struct {
	URL   string
	Cause error
}

RegistrationFailure retains endpoint identity across the aggregate readiness result, so applications can recover the rejected authority without parsing text.

func (*RegistrationFailure) Error

func (failure *RegistrationFailure) Error() string

func (*RegistrationFailure) Unwrap

func (failure *RegistrationFailure) Unwrap() error

type Sender

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

func NewSender

func NewSender(parent context.Context, urls []string, dial SenderFactory) (*Sender, error)

func (*Sender) Accept

func (s *Sender) Accept(ctx context.Context) (*relayv2.Channel, error)

func (*Sender) Availability

func (s *Sender) Availability() SenderAvailability

Availability reads the owner's current state even when observations were dropped.

func (*Sender) Cleanup

func (s *Sender) Cleanup(ctx context.Context) error

func (*Sender) ObserveAvailability

func (s *Sender) ObserveAvailability(observer func(SenderAvailability))

func (*Sender) ReadyRelayURL

func (s *Sender) ReadyRelayURL() string

func (*Sender) Registrations

func (s *Sender) Registrations() SenderRegistrations

Registrations freezes what is known at publication. Pending candidates can still become useful after the first relay releases the share link.

func (*Sender) StopRecovery

func (s *Sender) StopRecovery()

func (*Sender) WaitReady

func (s *Sender) WaitReady(ctx context.Context) error

func (*Sender) Wake

func (s *Sender) Wake()

type SenderAvailability

type SenderAvailability struct {
	Available uint32
	Total     uint32
	EverReady bool
	Terminal  uint32
}

SenderAvailability describes only admission through relays. Existing direct transfers have independent lifetimes and must never be inferred from this count.

type SenderEndpoint

type SenderEndpoint interface {
	WaitReady(context.Context) error
	SetAvailabilityObserver(func(bool))
	Wake()
	Accept(context.Context) (*relayv2.Channel, error)
	StopRecovery()
	Cleanup(context.Context) error
}

type SenderFactory

type SenderFactory func(context.Context, string) (SenderEndpoint, error)

type SenderRegistrations

type SenderRegistrations struct {
	Admitted []string
	Rejected []string
}

Jump to

Keyboard shortcuts

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