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 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 cache 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. |