Documentation ¶
Index ¶
- func Decode(ctx context.Context, name string) (proto.Message, error)
- func GetAmbassadorDrainTime(ctx context.Context) time.Duration
- func JoinEdsClusters(ctx context.Context, clusters []ecp_cache_types.Resource, ...) (endpoints []ecp_cache_types.Resource)
- func JoinEdsClustersV3(ctx context.Context, clusters []ecp_cache_types.Resource, ...) (endpoints []ecp_cache_types.Resource)
- func ListenerToRdsListener(lnr *apiv2.Listener) (*apiv2.Listener, []*apiv2.RouteConfiguration, error)
- func Main(ctx context.Context, Version string, rawArgs ...string) error
- func Main2(ctx context.Context, Version string, getUsage MemoryGetter, ...) error
- func NewV2ExpandedSnapshot(v2snap *ecp_v2_cache.Snapshot) v2ExpandedSnapshot
- func NewV3ExpandedSnapshot(v3snap *ecp_v3_cache.Snapshot) v3ExpandedSnapshot
- func Updater(ctx context.Context, updates <-chan Update, getUsage MemoryGetter) error
- func V3ListenerToRdsListener(lnr *apiv3_listener.Listener) (*apiv3_listener.Listener, []*apiv3_route.RouteConfiguration, error)
- type Args
- type Endpoint
- type Endpoints
- type FastpathSnapshot
- type HasherV2
- type HasherV3
- type MemoryGetter
- type Update
- type Validatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAmbassadorDrainTime ¶
The GetAmbassadorDrainTime function retuns the AMBASSADOR_DRAIN_TIME env var as a time.Duration
func JoinEdsClusters ¶
func JoinEdsClusters(ctx context.Context, clusters []ecp_cache_types.Resource, edsEndpoints map[string]*apiv2.ClusterLoadAssignment) (endpoints []ecp_cache_types.Resource)
JoinEdsClusters will perform an outer join operation between the eds clusters in the supplied clusterlist and the eds endpoint data in the supplied map. It will return a slice of ClusterLoadAssignments (cast to []ecp_cache_types.Resource) with endpoint data for all the eds clusters in the supplied list. If there is no map entry for a given cluster, an empty ClusterLoadAssignment will be synthesized. The result is a set of endpoints that are consistent (by the go-control-plane's definition of consistent) with the input clusters.
func JoinEdsClustersV3 ¶
func JoinEdsClustersV3(ctx context.Context, clusters []ecp_cache_types.Resource, edsEndpoints map[string]*apiv3_endpoint.ClusterLoadAssignment) (endpoints []ecp_cache_types.Resource)
JoinEdsClustersV3 will perform an outer join operation between the eds clusters in the supplied clusterlist and the eds endpoint data in the supplied map. It will return a slice of ClusterLoadAssignments (cast to []ecp_cache_types.Resource) with endpoint data for all the eds clusters in the supplied list. If there is no map entry for a given cluster, an empty ClusterLoadAssignment will be synthesized. The result is a set of endpoints that are consistent (by the go-control-plane's definition of consistent) with the input clusters.
func ListenerToRdsListener ¶
func ListenerToRdsListener(lnr *apiv2.Listener) (*apiv2.Listener, []*apiv2.RouteConfiguration, error)
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 Main ¶
NOTE WELL: this Main() does NOT RUN from entrypoint! This one is only relevant if you explicitly run Ambex by hand.
func Main2 ¶
func Main2( ctx context.Context, Version string, getUsage MemoryGetter, fastpathCh <-chan *FastpathSnapshot, rawArgs ...string, ) error
func NewV2ExpandedSnapshot ¶
func NewV2ExpandedSnapshot(v2snap *ecp_v2_cache.Snapshot) v2ExpandedSnapshot
func NewV3ExpandedSnapshot ¶
func NewV3ExpandedSnapshot(v3snap *ecp_v3_cache.Snapshot) v3ExpandedSnapshot
func Updater ¶
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.
func V3ListenerToRdsListener ¶
func V3ListenerToRdsListener(lnr *apiv3_listener.Listener) (*apiv3_listener.Listener, []*apiv3_route.RouteConfiguration, error)
V3ListenerToRdsListener is the v3 variety of ListnerToRdsListener
Types ¶
type Endpoint ¶
Endpoint contains the subset of fields we bother to expose.
func (*Endpoint) ToLbEndpoint_v2 ¶
func (e *Endpoint) ToLbEndpoint_v2() *v2endpoint.LbEndpoint
ToLBEndpoint_v2 translates to envoy v2 frinedly form of the Endpoint data.
func (*Endpoint) ToLbEndpoint_v3 ¶
func (e *Endpoint) ToLbEndpoint_v3() *v3endpoint.LbEndpoint
ToLBEndpoint_v3 translates to envoy v3 frinedly form of the Endpoint data.
type Endpoints ¶
The Endpoints struct is how Endpoint data gets communicated to ambex. This is a bit simpler than the envoy endpoint data structures, and also provides us a layer of indirection to buffer us from changes in envoy configuration, e.g. we can switch from v2 to v3 endpoint data, or add v3 endpoint data fairly easily with this layer of indirection.
func (*Endpoints) RoutesString ¶
func (*Endpoints) ToMap_v2 ¶
func (e *Endpoints) ToMap_v2() map[string]*v2.ClusterLoadAssignment
ToMap_v2 produces a map with the envoy v2 friendly forms of all the endpoint data.
func (*Endpoints) ToMap_v3 ¶
func (e *Endpoints) ToMap_v3() map[string]*v3endpointconfig.ClusterLoadAssignment
ToMap_v3 produces a map with the envoy v3 friendly forms of all the endpoint data.
type FastpathSnapshot ¶
type FastpathSnapshot struct { Snapshot *ecp_v2_cache.Snapshot Endpoints *Endpoints }
FastpathSnapshot holds envoy configuration that bypasses python.
type MemoryGetter ¶
type MemoryGetter func() int
Function type for fetching memory usage as a percentage.
type Update ¶
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.