Documentation ¶
Index ¶
- Constants
- func DrainListeners(adminPort uint32, inboundonly bool) error
- func GetConfigDump(adminPort uint32) (*envoyAdmin.ConfigDump, error)
- func GetServerInfo(adminPort uint32) (*envoyAdmin.ServerInfo, error)
- func Shutdown(adminPort uint32) error
- type Agent
- type BaseID
- type ComponentLogLevel
- type ComponentLogLevels
- type Config
- type Epoch
- type FactoryFunc
- type FlagName
- type IPVersion
- type Instance
- type LogLevel
- type Option
- func Concurrency(concurrency uint16) Option
- func ConfigPath(path string) Option
- func ConfigYaml(yaml string) Option
- func DisableHotRestart(disable bool) Option
- func DrainDuration(duration time.Duration) Option
- func LocalAddressIPVersion(v IPVersion) Option
- func LogFormat(format string) Option
- func LogPath(path string) Option
- func ParentShutdownDuration(duration time.Duration) Option
- func ServiceCluster(c string) Option
- func ServiceNode(n string) Option
- type Options
- type Proxy
- type ProxyConfig
- type Waitable
Constants ¶
const ( // InvalidBaseID used to indicate that the Envoy BaseID has not been set. Attempting // to Close this BaseID will have no effect. InvalidBaseID = BaseID(math.MaxUint32) )
Variables ¶
This section is empty.
Functions ¶
func DrainListeners ¶
DrainListeners drains inbound listeners of Envoy so that inflight requests can gracefully finish and even continue making outbound calls as needed.
func GetConfigDump ¶
func GetConfigDump(adminPort uint32) (*envoyAdmin.ConfigDump, error)
GetConfigDump polls Envoy admin port for the config dump and returns the response.
func GetServerInfo ¶
func GetServerInfo(adminPort uint32) (*envoyAdmin.ServerInfo, error)
GetServerInfo returns a structure representing a call to /server_info
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
type BaseID ¶
type BaseID uint32
BaseID is an Option that sets the --base-id flag. This is typically only needed when running multiple Envoys on the same machine (common in testing environments).
Envoy will allocate shared memory if provided with a BaseID. This shared memory is used during hot restarts. It is up to the caller to free this memory by calling Close() on the BaseID when appropriate.
func GenerateBaseID ¶
func GenerateBaseID() BaseID
GenerateBaseID is a method copied from Envoy server tests.
Computes a numeric ID to incorporate into the names of shared-memory segments and domain sockets, to help keep them distinct from other tests that might be running concurrently.
func (BaseID) GetInternalEnvoyValue ¶
GetInternalEnvoyValue returns the value used internally by Envoy.
type ComponentLogLevel ¶
ComponentLogLevel defines the log level for a single component.
func (ComponentLogLevel) String ¶
func (l ComponentLogLevel) String() string
type ComponentLogLevels ¶
type ComponentLogLevels []ComponentLogLevel
ComponentLogLevels is an Option for multiple component log levels.
func ParseComponentLogLevels ¶
func ParseComponentLogLevels(value string) ComponentLogLevels
ParseComponentLogLevels parses the given envoy --component-log-level value string.
func (ComponentLogLevels) FlagName ¶
func (l ComponentLogLevels) FlagName() FlagName
func (ComponentLogLevels) FlagValue ¶
func (l ComponentLogLevels) FlagValue() string
type Config ¶
type Config struct { // Options provides the command-line options to be passed to Envoy. Options Options // Name of the envoy instance, used for logging only. If not provided, defaults to "envoy". Name string // BinaryPath the path to the Envoy binary. BinaryPath string // WorkingDir to be used when running Envoy. If not set, the current working directory is used. WorkingDir string // AdminPort specifies the administration port for the Envoy server. If not set, will // be determined by parsing the Envoy bootstrap configuration file. AdminPort uint32 // SkipBaseIDClose skips calling Close on the BaseID, if one was specified. SkipBaseIDClose bool }
Config for an Envoy Instance.
type Epoch ¶
type Epoch uint32
Epoch sets the --restart-epoch flag, which specifies the epoch used for hot restart.
type FactoryFunc ¶
FactoryFunc is a function that manufactures Envoy Instances.
type IPVersion ¶
type IPVersion string
IPVersion is an enumeration for IP versions for the --local-address-ip-version flag.
type Instance ¶
type Instance interface { // Config returns the configuration for this Instance. Config() Config // BaseID used to start Envoy. If not set, returns InvalidBaseID. BaseID() BaseID // Epoch used to start Envoy. If it was not set, defaults to 0. Epoch() Epoch // Start the Envoy Instance. The process will be killed if the given context is canceled. // // If this Instance was created via NewInstanceForHotRestart, this method will block until the parent // Instance terminates or goes "live". This is due to the fact that hot restart will fail if the previous // envoy process is still initializing. Start(ctx context.Context) Instance // NewInstanceForHotRestart creates a new Envoy Instance that is configured for a hot restart of this // Instance (i.e. epoch is incremented). During a hot restart of Envoy, the old process is drained and // traffic is shifted over to the new process. // // The caller must Start the returned instance to initiate the hot restart. // // If a new Instance is successfully created, it assumes ownership of the Envoy shared memory segment // used for hot restart. This means that when this Instance exits, it will no longer destroy // the shared memory segment, regardless of the value of SkipBaseIDClose. // // If this Instance hasn't been started, calling this method does nothing and simply returns // this Instance since there is nothing to restart. // // This method may only be called once on a given Instance. Subsequent calls will return an error. NewInstanceForHotRestart() (Instance, error) // WaitUntilLive polls the Envoy ServerInfo endpoint and waits for it to transition to "live". If the // wait times out, returns the last known error or context.DeadlineExceeded if no error occurred within the // specified duration. WaitLive() Waitable // AdminPort gets the administration port for Envoy. AdminPort() uint32 // GetServerInfo returns a structure representing a call to /server_info GetServerInfo() (*envoyAdmin.ServerInfo, error) // GetConfigDump polls Envoy admin port for the config dump and returns the response. GetConfigDump() (*envoyAdmin.ConfigDump, error) // Wait for the Instance to terminate. Wait() Waitable // Kill the process, if running. Kill() error // KillAndWait is a helper that calls Kill and then waits for the process to terminate. KillAndWait() Waitable // Shutdown initiates the graceful termination of Envoy. Returns immediately and does not // wait for the process to exit. Shutdown() error // ShutdownAndWait is a helper that calls Shutdown and waits for the process to terminate. ShutdownAndWait() Waitable // DrainListeners drains listeners of Envoy so that inflight requests // can gracefully finish and even continue making outbound calls as needed. DrainListeners() error }
Instance of an Envoy process.
type Option ¶
type Option interface { // FlagName returns the flag name used on the command line. FlagName() FlagName // FlagValue returns the flag value used on the command line. Can be empty for boolean flags. FlagValue() string // contains filtered or unexported methods }
Option for an Envoy Instance.
func Concurrency ¶
Concurrency sets the --concurrency flag, which sets the number of worker threads to run.
func ConfigPath ¶
ConfigPath sets the --config-path flag, which provides Envoy with the to the v2 bootstrap configuration file. If not set, ConfigYaml is required.
func ConfigYaml ¶
ConfigYaml sets the --config-yaml flag, which provides Envoy with the a YAML string for a v2 bootstrap configuration. If ConfigPath is also set, the values in this YAML string will override and merge with the bootstrap loaded from ConfigPath.
func DisableHotRestart ¶
DisableHotRestart sets the --disable-hot-restart flag.
func DrainDuration ¶
DrainDuration sets the --drain-time-s flag, which defines the amount of time that Envoy will drain connections during a hot restart.
func LocalAddressIPVersion ¶
LocalAddressIPVersion sets the --local-address-ip-version flag, which sets the IP address version used for the local IP address. The default is V4.
func LogFormat ¶
LogFormat sets the --log-format flag, which specifies the format string to use for log messages.
func LogPath ¶
LogPath sets the --log-path flag, which specifies the output file for logs. If not set logs will be written to stderr.
func ParentShutdownDuration ¶
ParentShutdownDuration sets the --parent-shutdown-time-s flag, which defines the amount of time that Envoy will wait before shutting down the parent process during a hot restart
func ServiceCluster ¶
ServiceCluster sets the --service-cluster flag, which defines the local service cluster name where Envoy is running
func ServiceNode ¶
ServiceNode sets the --service-node flag, which defines the local service node name where Envoy is running
type Options ¶
type Options []Option
func NewOptions ¶
NewOptions creates new Options from the given raw Envoy arguments. Returns an error if a problem was encountered while parsing the arguments.
type Proxy ¶
type Proxy interface { // Run command for an epoch, and abort channel Run(int, <-chan error) error // Drains the current epoch. Drain() error // Cleanup command for an epoch Cleanup(int) // UpdateConfig writes a new config file UpdateConfig(config []byte) error }
Proxy defines command interface for a proxy
func NewProxy ¶
func NewProxy(cfg ProxyConfig) Proxy
NewProxy creates an instance of the proxy control commands
type ProxyConfig ¶
type ProxyConfig struct { LogLevel string ComponentLogLevel string NodeIPs []string Sidecar bool LogAsJSON bool // TODO: outlier log path configuration belongs to mesh ProxyConfig OutlierLogPath string BinaryPath string ConfigPath string ConfigCleanup bool AdminPort int32 DrainDuration *durationpb.Duration ParentShutdownDuration *durationpb.Duration Concurrency int32 // For unit testing, in combination with NoEnvoy prevents agent.Run from blocking TestOnly bool AgentIsRoot bool }
Envoy binary flags
type Waitable ¶
type Waitable interface { // WithTimeout specifies an upper bound on the wait time. WithTimeout(timeout time.Duration) Waitable // Do performs the wait. By default, waits indefinitely. To specify an upper bound on // the wait time, use WithTimeout. If the wait times out, returns the last known error // for retried operations or context.DeadlineExceeded if no previous error was encountered. Do() error }
Waitable specifies a waitable operation.