senderrelay

package
v0.1.3 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: 16 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
	AuthorizationExpired          = serviceauthority.AdmissionExpired
	AuthorizationTemporaryFailure = serviceauthority.AdmissionTemporaryFailure
	AuthorizationDenied           = serviceauthority.AdmissionDenied
)
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
	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
)

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 {
	RegistrationAuthorization() Authorization
}

AuthorizationSource performs no network I/O. A snapshot and its change signal belong to the same revision, so setup completion cannot be lost between them.

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
	Wait(context.Context, time.Duration) 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) SetAvailabilityObserver

func (lifecycle *Lifecycle) SetAvailabilityObserver(observer func(bool))

SetAvailabilityObserver installs the aggregate ingress observer before startup. It reports the current state immediately, so a fast initial connection is not lost.

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 StaticKey

type StaticKey string

func (StaticKey) RegistrationAuthorization

func (key StaticKey) RegistrationAuthorization() Authorization

Jump to

Keyboard shortcuts

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