Documentation ¶
Index ¶
- func Clone(src proto.Message) proto.Message
- func Decode(name string) (proto.Message, error)
- func GetAmbassadorDrainTime() time.Duration
- func ListenerToRdsListener(lnr *api.Listener) (*api.Listener, []*api.RouteConfiguration, error)
- func Main(ctx context.Context, Version string, rawArgs ...string) error
- func Main2(ctx context.Context, Version string, getUsage MemoryGetter, rawArgs ...string) error
- func Merge(to, from proto.Message)
- func Updater(ctx context.Context, updates <-chan Update, getUsage MemoryGetter) error
- type Args
- type Hasher
- type MemoryGetter
- type Update
- type Validatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAmbassadorDrainTime ¶ added in v1.9.0
The GetAmbassadorDrainTime function retuns the AMBASSADOR_DRAIN_TIME env var as a time.Duration
func ListenerToRdsListener ¶ added in v1.11.0
ListenerToRdsListener will take a listener definition and extract any inline RouteConfigurations replacing them with a reference to an RDS supplied route configuration. It does not modify the supplied listener, any configuration included in the result is copied from the input.
If the input listener does not match the expected form it is simply copied, i.e. it is the identity transform for any inputs not matching the expected form.
Example Input (that will get transformed in a non-identity way):
a listener configured with an http connection manager
that specifies an http router
that supplies its RouteConfiguration inline via the route_config field
{ "name": "...", ..., "filter_chains": [ { "filter_chain_match": {...}, "filters": [ { "name": "envoy.filters.network.http_connection_manager", "typed_config": { "@type": "type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager", "http_filters": [...], "route_config": { "virtual_hosts": [ { "name": "ambassador-listener-8443-*", "domains": ["*"], "routes": [...], } ] } } } ] } ] }
Example Output:
a duplicate listener that defines the "rds" field instead of the "route_config" field
and a list of route configurations
with route_config_name supplied in such a way as to correlate the two together
lnr, routes, err := ListenerToRdsListener(...)
lnr = { "name": "...", ..., "filter_chains": [ { "filter_chain_match": {...}, "filters": [ { "name": "envoy.filters.network.http_connection_manager", "typed_config": { "@type": "type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager", "http_filters": [...], "rds": { "config_source": { "ads": {} }, "route_config_name": "ambassador-listener-8443-routeconfig-0" } } } ] } ] }
routes = [ { "name": "ambassador-listener-8443-routeconfig-0", "virtual_hosts": [ { "name": "ambassador-listener-8443-*", "domains": ["*"], "routes": [...], } ] } ]
func Updater ¶ added in v1.9.0
func Updater(ctx context.Context, updates <-chan Update, getUsage MemoryGetter) error
The Updator function will run forever (or until the ctx is canceled) and look for updates on the incoming channel. If memory usage is constrained as reported by the getUsage function, updates will be rate limited to guarantee that there are only so many stale configs in memory at a time. The function assumes updates are cumulative and it will drop old queued updates if a new update arrives.
Types ¶
type MemoryGetter ¶ added in v1.9.0
type MemoryGetter func() int
Function type for fetching memory usage as a percentage.
type Update ¶ added in v1.9.0
An Update encapsulates everything needed to perform an update (of envoy configuration). The version string is for logging purposes, the Updator func does the actual work of updating.
type Validatable ¶
Not sure if there is a better way to do this, but we cast to this so we can call the generated Validate method.