Documentation
¶
Overview ¶
Package relayset coordinates independent relay endpoint lifecycles. Each endpoint retains registration/resume authority; the set only merges ingress.
Index ¶
- Constants
- Variables
- func PublicURLs(candidates []Candidate) ([]string, error)
- type Admission
- type Attempt
- type AttemptControl
- type AttemptPermit
- type AttemptState
- type Authorization
- type AuthorizationError
- type AuthorizationSource
- type AuthorizationState
- type Candidate
- type Clock
- type Fallback
- type NetworkAdmissions
- type Receiver
- type ReceiverClock
- type ReceiverConfig
- type ReceiverConnection
- type ReceiverJoinFailure
- type ReceiverRecovery
- type ReceiverRecoveryObservation
- type ReceiverRecoveryOptions
- type ReceiverRecoveryPhase
- type RegistrationFailure
- type RegistrationState
- type Sender
- func (s *Sender) Accept(ctx context.Context) (*relayv2.Channel, error)
- func (s *Sender) Cleanup(ctx context.Context) error
- func (s *Sender) ObserveStatus(observer func(SenderStatus))
- func (s *Sender) ReadyRelayURL() string
- func (s *Sender) Registrations() SenderRegistrations
- func (s *Sender) Status() SenderStatus
- func (s *Sender) StopRecovery()
- func (s *Sender) WaitReady(ctx context.Context) error
- func (s *Sender) Wake()
- type SenderAvailability
- type SenderConnection
- func (connection SenderConnection) Accept(ctx context.Context) (*relayv2.Channel, error)
- func (connection SenderConnection) Close() error
- func (connection SenderConnection) CompleteObservations() relayv2.LifecycleObservationCompletion
- func (connection SenderConnection) LifecycleTrace() <-chan relayv2.LifecycleTrace
- type SenderDialer
- type SenderEndpoint
- type SenderFactory
- type SenderLifecycle
- func (lifecycle *SenderLifecycle) Accept(ctx context.Context) (*relayv2.Channel, error)
- func (lifecycle *SenderLifecycle) Cleanup(ctx context.Context) error
- func (lifecycle *SenderLifecycle) CompleteObservations() relayv2.LifecycleObservationCompletion
- func (lifecycle *SenderLifecycle) ObserveRegistration(observer func(RegistrationState))
- func (lifecycle *SenderLifecycle) StopRecovery()
- func (lifecycle *SenderLifecycle) WaitReady(ctx context.Context) error
- func (lifecycle *SenderLifecycle) Wake()
- type SenderLifecycleConfig
- type SenderRegistrations
- type SenderStatus
- type SenderTransport
- type StaticKey
- type SystemClock
Constants ¶
const ( AdmissionAdmitted = "admitted" AdmissionParked = "parked" )
const ( AdmissionReasonPrimary = "primary" AdmissionReasonBackup = "backup" AdmissionReasonPermitReleased = "permit_released" AdmissionReasonTargetReached = "target_reached" AdmissionReasonBackupNotChosen = "backup_not_selected" AdmissionReasonPrimaryLost = "primary_lost" AdmissionReasonBackupLost = "backup_lost" )
const ( AuthorizationReady = serviceauthority.AdmissionReady AuthorizationPendingSetup = serviceauthority.AdmissionPendingSetup AuthorizationPendingAttribution = serviceauthority.AdmissionPendingAttribution AuthorizationExpired = serviceauthority.AdmissionExpired AuthorizationTemporaryFailure = serviceauthority.AdmissionTemporaryFailure AuthorizationDenied = serviceauthority.AdmissionDenied AuthorizationUserActionRequired = serviceauthority.AdmissionUserActionRequired )
const MaxAccessKeyBytes = 4096
const MaximumEndpoints = 8
const (
ReceiverInitialWait = 10 * time.Second
)
Variables ¶
var ( ErrReceiverWaitExpired = errors.New("receiver connection waiting deadline expired") )
var ErrCandidate = errors.New("invalid sender relay candidate")
var ErrConfig = errors.New("invalid sender relay set configuration")
var ErrReceiverAuthentication = errors.New("receiver relay authentication failed")
var ErrStopped = senderRelayRecoveryStoppedError{}
Functions ¶
func PublicURLs ¶ added in v0.1.6
PublicURLs validates the entire publication before any candidate can register. Aliases of the same relay identity would compete for one share's ownership.
Types ¶
type AttemptControl ¶ added in v0.1.6
type AttemptControl interface {
Begin(context.Context) (AttemptPermit, error)
}
AttemptControl limits individual handshakes, leaving retry clocks and resume authority with the endpoint. Waiting for capacity must not consume a dial timeout.
type AttemptPermit ¶ added in v0.1.6
type AttemptPermit interface {
Admit() bool
Release()
ReleaseFailed()
}
AttemptPermit tracks one in-flight handshake slot. ReleaseFailed records an actual handshake failure for in-share backup ranking, whereas Release frees the slot without penalizing the candidate (admitted, parked, auth wait, cancel).
type AttemptState ¶ added in v0.1.6
type AttemptState uint8
const ( AttemptStarted AttemptState = iota + 1 AttemptSucceeded AttemptFailed AttemptWaiting AttemptParked AttemptStage AttemptAuthorization )
func (AttemptState) DiagnosticName ¶ added in v0.1.6
func (value AttemptState) DiagnosticName() string
DiagnosticName belongs to the source vocabulary; recorders accept new values.
type Authorization ¶ added in v0.1.6
type Authorization = serviceauthority.RegistrationAuthorization
type AuthorizationError ¶ added in v0.1.6
type AuthorizationError struct {
State AuthorizationState
Cause error
}
func (*AuthorizationError) Error ¶ added in v0.1.6
func (err *AuthorizationError) Error() string
func (*AuthorizationError) Unwrap ¶ added in v0.1.6
func (err *AuthorizationError) Unwrap() error
type AuthorizationSource ¶ added in v0.1.6
type AuthorizationSource interface {
ReserveRegistrationAuthorization() Authorization
}
AuthorizationSource reserves authorization for one fresh registration. Waiting results describe the revision to watch and hold no reservation or dial slot.
type AuthorizationState ¶ added in v0.1.6
type AuthorizationState = serviceauthority.AdmissionState
type Candidate ¶ added in v0.1.6
type Candidate struct {
PublicURL string
Authorization AuthorizationSource `json:"-"`
}
Candidate binds deployment registration authority to one public relay address. Only PublicURL may enter a capability; the token is not session/STOP authority.
type Fallback ¶ added in v0.1.6
Fallback records the one-shot startup transition to standby canary relays after every initial active network candidate fails its first attempt.
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 (*NetworkAdmissions) Control ¶
func (a *NetworkAdmissions) Control(url string) AttemptControl
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) AllRelaysStopped ¶ added in v0.1.5
AllRelaysStopped requires an explicit stop from every route in the link's resolved candidate set. Missing directory results and temporary failures leave open the possibility of joining the same share again.
func (*Receiver) WaitReady ¶
func (receiver *Receiver) WaitReady(ctx context.Context) (*receiversession.Runtime, ReceiverConnection, error)
type ReceiverClock ¶
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 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 ¶
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 RegistrationState ¶ added in v0.1.6
type RegistrationState uint8
const ( RegistrationPending RegistrationState = iota RegistrationNeedsUserAuthorization RegistrationRetrying RegistrationAvailable )
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
func NewPlannedSender ¶ added in v0.1.6
func (*Sender) ObserveStatus ¶ added in v0.1.4
func (s *Sender) ObserveStatus(observer func(SenderStatus))
ObserveStatus delivers the current status immediately and subsequent aggregate transitions synchronously and in causal order while holding s.mu (and, on endpoint-driven transitions, the endpoint's registration lock). Holding the lock keeps transitions serialized and suppresses notifications atomically once StopRecovery runs. The callback must not block or reenter Sender (including via StopRecovery).
func (*Sender) ReadyRelayURL ¶
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) Status ¶ added in v0.1.4
func (s *Sender) Status() SenderStatus
Status reads the owner's current state even when observations were dropped.
func (*Sender) StopRecovery ¶
func (s *Sender) StopRecovery()
type SenderAvailability ¶
SenderAvailability describes only admission through relays. Existing direct transfers have independent lifetimes and must never be inferred from this count.
type SenderConnection ¶ added in v0.1.6
type SenderConnection struct {
// contains filtered or unexported fields
}
SenderConnection keeps factories concrete while containing the narrow transport interface at the consumer boundary.
func NewSenderConnection ¶ added in v0.1.6
func NewSenderConnection(endpoint SenderTransport) SenderConnection
func (SenderConnection) Close ¶ added in v0.1.6
func (connection SenderConnection) Close() error
func (SenderConnection) CompleteObservations ¶ added in v0.1.6
func (connection SenderConnection) CompleteObservations() relayv2.LifecycleObservationCompletion
func (SenderConnection) LifecycleTrace ¶ added in v0.1.6
func (connection SenderConnection) LifecycleTrace() <-chan relayv2.LifecycleTrace
type SenderDialer ¶ added in v0.1.6
type SenderDialer interface {
Dial(context.Context, relayv2.SenderConfig) (SenderConnection, error)
}
SenderDialer owns the complete attempt outcome. RegistrationNotSentError proves no registration was sent by any internal attempt; observations never own policy.
type SenderEndpoint ¶
type SenderFactory ¶
type SenderFactory func(context.Context, string) (SenderEndpoint, error)
type SenderLifecycle ¶ added in v0.1.6
type SenderLifecycle struct {
// contains filtered or unexported fields
}
SenderLifecycle owns one relay's registration for the lifetime of a share.
func NewSenderLifecycle ¶ added in v0.1.6
func NewSenderLifecycle(config SenderLifecycleConfig) (*SenderLifecycle, error)
func (*SenderLifecycle) Cleanup ¶ added in v0.1.6
func (lifecycle *SenderLifecycle) Cleanup(ctx context.Context) error
func (*SenderLifecycle) CompleteObservations ¶ added in v0.1.6
func (lifecycle *SenderLifecycle) CompleteObservations() relayv2.LifecycleObservationCompletion
func (*SenderLifecycle) ObserveRegistration ¶ added in v0.1.6
func (lifecycle *SenderLifecycle) ObserveRegistration(observer func(RegistrationState))
ObserveRegistration provides the current route state even when diagnostic observations are disabled or dropped. The callback must not reenter SenderLifecycle.
func (*SenderLifecycle) StopRecovery ¶ added in v0.1.6
func (lifecycle *SenderLifecycle) StopRecovery()
func (*SenderLifecycle) WaitReady ¶ added in v0.1.6
func (lifecycle *SenderLifecycle) WaitReady(ctx context.Context) error
WaitReady waits through temporary startup failures. Only authenticated readiness makes a link publishable; merely constructing a lifecycle does not.
func (*SenderLifecycle) Wake ¶ added in v0.1.6
func (lifecycle *SenderLifecycle) Wake()
Wake coalesces network/resume notifications into the single recovery owner.
type SenderLifecycleConfig ¶ added in v0.1.6
type SenderLifecycleConfig struct {
Candidate Candidate
Fresh v2.RegisterInit
ResumeToken v2.ResumeToken
PrivateKey ed25519.PrivateKey
Descriptor []byte
Initial SenderTransport
Dialer SenderDialer
Clock Clock
LifecycleObservationCapacity int
ObserveConnection func(SenderConnection) func()
ObserveAttempt func(Attempt)
Attempts AttemptControl
// Jitter is applied only in the slow phase, keeping short outages responsive.
Jitter func(time.Duration) time.Duration
}
type SenderRegistrations ¶
type SenderStatus ¶ added in v0.1.4
type SenderStatus struct {
Availability SenderAvailability
AuthorizationRequired bool
}
type SenderTransport ¶ added in v0.1.6
SenderTransport is defined at the lifecycle that consumes it so recovery policy does not depend on the concrete WebSocket transport.
type StaticKey ¶ added in v0.1.6
type StaticKey string
func (StaticKey) ReserveRegistrationAuthorization ¶ added in v0.1.6
func (key StaticKey) ReserveRegistrationAuthorization() Authorization
type SystemClock ¶ added in v0.1.6
type SystemClock struct{}
func (SystemClock) Now ¶ added in v0.1.6
func (SystemClock) Now() time.Time