senderrelay

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 18 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 senderrelay owns one relay's registration for the lifetime of a share.

Index

Constants

View Source
const (
	AuthorizationReady              = serviceauthority.AdmissionReady
	AuthorizationPendingSetup       = serviceauthority.AdmissionPendingSetup
	AuthorizationPendingAttribution = serviceauthority.AdmissionPendingAttribution
	AuthorizationExpired            = serviceauthority.AdmissionExpired
	AuthorizationTemporaryFailure   = serviceauthority.AdmissionTemporaryFailure
	AuthorizationDenied             = serviceauthority.AdmissionDenied
	AuthorizationUserActionRequired = serviceauthority.AdmissionUserActionRequired
)
View Source
const MaxAccessKeyBytes = 4096

Variables

View Source
var ErrCandidate = errors.New("invalid sender relay candidate")
View Source
var ErrStopped = senderRelayRecoveryStoppedError{}

Functions

func PublicURLs

func PublicURLs(candidates []Candidate) ([]string, error)

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 Attempt

type Attempt struct {
	ShareInstance     v2.ShareInstance
	Number            uint32
	State             AttemptState
	Failure           error
	Generation        uint64
	Slow              bool
	Resume            bool
	NextDelay         time.Duration
	ServerRetryAt     time.Time
	HandshakeDuration time.Duration
	Terminal          bool
	Duration          time.Duration
	Stage             string
	Authorization     AuthorizationState
}

type AttemptControl

type AttemptControl interface {
	Begin(context.Context) (AttemptPermit, error)
	Unavailable()
}

AttemptControl limits individual handshakes, leaving retry clocks and resume authority with the endpoint. Waiting for capacity must not consume a dial timeout.

type AttemptPermit

type AttemptPermit interface {
	Admit() bool
	Release()
}

type AttemptState

type AttemptState uint8
const (
	AttemptStarted AttemptState = iota + 1
	AttemptSucceeded
	AttemptFailed
	AttemptWaiting
	AttemptParked
	AttemptStage
	AttemptAuthorization
)

func (AttemptState) DiagnosticName added in v0.1.5

func (value AttemptState) DiagnosticName() string

DiagnosticName belongs to the source vocabulary; recorders accept new values.

type AuthorizationError

type AuthorizationError struct {
	State AuthorizationState
	Cause error
}

func (*AuthorizationError) Error

func (err *AuthorizationError) Error() string

func (*AuthorizationError) Unwrap

func (err *AuthorizationError) Unwrap() error

type AuthorizationSource

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

type AuthorizationState = serviceauthority.AdmissionState

type Candidate

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.

func (Candidate) Validate

func (candidate Candidate) Validate() error

type Clock

type Clock interface {
	Now() time.Time
	// A wake signal ends local backoff. A nil wake leaves only elapsed time or cancellation.
	Wait(context.Context, time.Duration, <-chan struct{}) error
}

type Config

type Config struct {
	Candidate                    Candidate
	Fresh                        v2.RegisterInit
	ResumeToken                  v2.ResumeToken
	PrivateKey                   ed25519.PrivateKey
	Descriptor                   []byte
	Initial                      Endpoint
	Dialer                       Dialer
	Clock                        Clock
	LifecycleObservationCapacity int
	ObserveConnection            func(Connection) 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 Connection

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

Connection keeps factories concrete while containing the narrow transport interface at the consumer boundary.

func NewConnection

func NewConnection(endpoint Endpoint) Connection

func (Connection) Accept

func (connection Connection) Accept(ctx context.Context) (*relayv2.Channel, error)

func (Connection) Close

func (connection Connection) Close() error

func (Connection) CompleteObservations

func (connection Connection) CompleteObservations() relayv2.LifecycleObservationCompletion

func (Connection) LifecycleTrace

func (connection Connection) LifecycleTrace() <-chan relayv2.LifecycleTrace

type Dialer

type Dialer interface {
	Dial(context.Context, relayv2.SenderConfig) (Connection, error)
}

Dialer owns the complete attempt outcome. RegistrationNotSentError proves no registration was sent by any internal attempt; observations never own policy.

type Endpoint

type Endpoint interface {
	Accept(context.Context) (*relayv2.Channel, error)
	Close() error
}

Endpoint is defined at the lifecycle that consumes it so recovery policy does not depend on the concrete WebSocket transport.

type Lifecycle

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

func New

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

func (*Lifecycle) Accept

func (lifecycle *Lifecycle) Accept(ctx context.Context) (*relayv2.Channel, error)

func (*Lifecycle) Cleanup

func (lifecycle *Lifecycle) Cleanup(ctx context.Context) error

func (*Lifecycle) CompleteObservations

func (lifecycle *Lifecycle) CompleteObservations() relayv2.LifecycleObservationCompletion

func (*Lifecycle) ObserveRegistration added in v0.1.4

func (lifecycle *Lifecycle) ObserveRegistration(observer func(RegistrationState))

ObserveRegistration provides the current route state even when diagnostic observations are disabled or dropped. The callback must not reenter Lifecycle.

func (*Lifecycle) StopRecovery

func (lifecycle *Lifecycle) StopRecovery()

func (*Lifecycle) WaitReady

func (lifecycle *Lifecycle) 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 (*Lifecycle) Wake

func (lifecycle *Lifecycle) Wake()

Wake coalesces network/resume notifications into the single recovery owner.

type RegistrationState added in v0.1.4

type RegistrationState uint8
const (
	RegistrationPending RegistrationState = iota
	RegistrationNeedsUserAuthorization
	RegistrationAvailable
)

type StaticKey

type StaticKey string

func (StaticKey) ReserveRegistrationAuthorization added in v0.1.4

func (key StaticKey) ReserveRegistrationAuthorization() Authorization

type SystemClock added in v0.1.5

type SystemClock struct{}

func (SystemClock) Now added in v0.1.5

func (SystemClock) Now() time.Time

func (SystemClock) Wait added in v0.1.5

func (SystemClock) Wait(ctx context.Context, delay time.Duration, wake <-chan struct{}) error

Jump to

Keyboard shortcuts

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