relayapp

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 22 Imported by: ? 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 relayapp wires and runs the relay proxy: the command line, the start, the reloads and the ordered stop. The main package of the binary only builds the signal context and calls Main.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(
	ctx context.Context, args []string, stdout, stderr io.Writer, lookupEnv func(string) (string, bool), build Build,
	changes ...Option,
) int

Main runs the relay on the environment that lookupEnv reads (the process reads it only in main.go) until ctx is cancelled (SIGTERM, SIGINT) and returns the exit code. SIGHUP reloads the bootstrap file. The options change what the process would use: the process passes none.

Types

type Build

type Build = buildinfo.Linked

Build is what the linker stamps into the binary (-X main.version=...).

type Option added in v1.0.0

type Option func(*Options)

Option changes the Options of a run of Main.

type Options added in v1.0.0

type Options struct {
	// Stdout receives the version and the banner, Stderr the logs.
	Stdout io.Writer
	Stderr io.Writer
	// OnDraining is called with the context of the shutdown once the readiness answers shutting-down and before the
	// drain delay starts.
	OnDraining func(ctx context.Context)
	// ShutdownContext returns the context of the shutdown, which must not be derived from the cancelled context of
	// the run. It ends when the relay is told to stop hard (the second signal). The context of a new signal
	// watcher when nil.
	ShutdownContext func(parent context.Context) (context.Context, context.CancelFunc)
	// DrainWait waits for the drain delay or for ctx; a test replaces it with a gate. The timer of the process
	// when nil.
	DrainWait func(ctx context.Context, delay time.Duration) error
	// WithTimeout bounds the stop that follows the drain delay, like [context.WithTimeout]; a test replaces it
	// with a context that it ends itself.
	WithTimeout func(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
	// Reload asks for a reload of the bootstrap file (SIGHUP).
	Reload <-chan struct{}
	// Load reads the file and the environment.
	Load bootstrap.LoadOptions
	// Deps are the injected dependencies of the core (a test scheduler, a state directory file system); the logger,
	// the metrics registry, the secrets and the broadcast of the streams are set by [run].
	Deps relaycore.Deps
	// Build is the version, commit and date stamped by the linker.
	Build Build
	// Args are the command line arguments, without the program name.
	Args []string
	// ServerOptions are added to the options of the API server (a test gives it its listeners).
	ServerOptions []api.Option
}

Options are the settings of a run of the relay: what the process gives it, and the seams that a caller of Main replaces (a listener, a scheduler, the contexts of the shutdown).

Directories

Path Synopsis
internal
cmdline
Package cmdline parses the command line of the relay: the flags that override the bootstrap file, --config, --help and --version.
Package cmdline parses the command line of the relay: the flags that override the bootstrap file, --config, --help and --version.

Jump to

Keyboard shortcuts

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