envoy

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// CurrentVersionWorkingDirFile is used for stable "versions" and "help" output
	CurrentVersionWorkingDirFile = "$PWD/.envoy-version"
	// CurrentVersionHomeDirFile is used for stable "versions" and "help" output
	CurrentVersionHomeDirFile = "$FUNC_E_HOME/version"
)

Variables

This section is empty.

Functions

func CurrentVersion

func CurrentVersion(homeDir string) (v version.Version, source string, err error)

CurrentVersion returns the first version in priority of VersionUsageList and its source or an error. The "source" and error messages returned include unexpanded variables to clarify the intended context. In the case no version was found, the version returned will be nil, not an error.

func InstallIfNeeded

func InstallIfNeeded(ctx context.Context, o *globals.GlobalOpts) (string, error)

InstallIfNeeded downloads an Envoy binary corresponding to globals.GlobalOpts and returns a path to it or an error.

func NewGetVersions added in v1.1.0

func NewGetVersions(envoyVersionsURL string, p version.Platform, v string) version.GetReleaseVersions

NewGetVersions creates a new Envoy versions fetcher. TODO: validate the data before returning it!

func VersionUsageList

func VersionUsageList() string

VersionUsageList is the priority order of Envoy version sources. This includes unresolved variables as it is both used statically for markdown generation, and also at runtime.

func WriteCurrentVersion

func WriteCurrentVersion(v version.Version, homeDir string) error

WriteCurrentVersion writes the version to CurrentVersionWorkingDirFile or CurrentVersionHomeDirFile depending on if the former is present.

Types

type LogFunc added in v1.2.0

type LogFunc func(format string, a ...any)

type Runtime

type Runtime struct {
	Out, Err         io.Writer
	OutFile, ErrFile *os.File
	// contains filtered or unexported fields
}

Runtime manages an Envoy lifecycle

func NewRuntime

func NewRuntime(opts *globals.RunOpts, logf LogFunc) *Runtime

NewRuntime creates a new Runtime that runs envoy in globals.RunOpts RunDir opts allows a user running envoy to control the working directory by ID or path, allowing explicit cleanup.

func (*Runtime) GetAdminAddress

func (r *Runtime) GetAdminAddress() (string, error)

GetAdminAddress returns the current admin address in host:port format, or empty if not yet available. Exported for admin data collection functionality.

func (*Runtime) GetRunDir

func (r *Runtime) GetRunDir() string

GetRunDir returns the run-specific directory files can be written to.

func (*Runtime) Run

func (r *Runtime) Run(ctx context.Context, args []string) error

Run execs the Envoy binary at the path with the args passed.

On success, this blocks and returns nil when either `ctx` is done, or the process exits with status zero.

func (*Runtime) String added in v1.0.0

func (r *Runtime) String() string

String is only used in tests. It is slow, but helps when debugging CI failures

type StartupHook added in v1.2.0

type StartupHook func(ctx context.Context, runDir, adminAddress string) error

StartupHook runs just after Envoy logs "starting main dispatch loop".

This is useful for callers who need access to two non-deterministic values:

1. The run directory (where stdout, stderr and the pid file are written) 2. The admin address (which is possibly ephemeral)

## Implementation Notes

Startup hooks are considered mandatory and will stop the run with error if failed. If your hook is optional, rescue panics and log your own errors.

Startup hooks run on the goroutine that consumes Envoy's STDERR. Envoy doesn't write a lot to stderr, so short tasks won't fill up the pipe and cause Envoy to block. However, if your hook is long-running, it must be run in a goroutine.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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