Documentation ¶
Overview ¶
Package endpointdiscovery provides a feature implemented in the AWS SDK for Go V2 that allows client to fetch a valid endpoint to serve an API request. Discovered endpoints are stored in an internal thread-safe cache to reduce the number of calls made to fetch the endpoint.
Endpoint discovery stores endpoint by associating to a generated cache key. Cache key is built using service-modeled sdkId and any service-defined input identifiers provided by the customer.
Endpoint cache keys follow the grammar:
key = sdkId.identifiers identifiers = map[string]string
The endpoint discovery cache implementation is internal. Clients resolves the cache size to 10 entries. Each entry may contain multiple host addresses as returned by the service.
Each discovered endpoint has a TTL associated to it, and are evicted from cache lazily i.e. when client tries to retrieve an endpoint but finds an expired entry instead.
Endpoint discovery feature can be turned on by setting the `AWS_ENABLE_ENDPOINT_DISCOVERY` env variable to TRUE.
By default, the feature is set to AUTO - indicating operations that require endpoint discovery always use it. To completely turn off the feature, one should set the value as FALSE. Similar configuration rules apply for shared config file where key is `endpoint_discovery_enabled`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscoverEndpoint ¶
type DiscoverEndpoint struct { // Options provides optional settings used with // Discover Endpoint operation. Options []func(*DiscoverEndpointOptions) // DiscoverOperation represents the endpoint discovery operation that // returns an Endpoint or error. DiscoverOperation func(ctx context.Context, options ...func(*DiscoverEndpointOptions)) (WeightedAddress, error) // EndpointDiscoveryEnableState represents the customer configuration for endpoint // discovery feature. EndpointDiscoveryEnableState aws.EndpointDiscoveryEnableState // EndpointDiscoveryRequired states if an operation requires to perform // endpoint discovery. EndpointDiscoveryRequired bool }
DiscoverEndpoint is a finalize step middleware used to discover endpoint for an API operation.
func (*DiscoverEndpoint) HandleFinalize ¶ added in v1.8.3
func (d *DiscoverEndpoint) HandleFinalize( ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler, ) (out middleware.FinalizeOutput, metadata middleware.Metadata, err error)
HandleFinalize performs endpoint discovery and updates the request host with the result.
The resolved host from this procedure MUST override that of modeled endpoint resolution and middleware should be ordered accordingly.
func (*DiscoverEndpoint) ID ¶
func (*DiscoverEndpoint) ID() string
ID represents the middleware identifier
type DiscoverEndpointOptions ¶
type DiscoverEndpointOptions struct { // EndpointResolverUsedForDiscovery is the endpoint resolver used to // resolve an endpoint for discovery api call. EndpointResolverUsedForDiscovery interface{} // DisableHTTPS will disable tls for endpoint discovery call and // subsequent discovered endpoint if service did not return an // endpoint scheme. DisableHTTPS bool // Logger to log warnings or debug statements. Logger logging.Logger }
DiscoverEndpointOptions are optionals used with DiscoverEndpoint operation.
type Endpoint ¶
type Endpoint struct { Key string Addresses WeightedAddresses }
Endpoint represents an endpoint used in endpoint discovery.
func (*Endpoint) Add ¶
func (e *Endpoint) Add(addr WeightedAddress)
Add will add a given WeightedAddress to the address list of Endpoint.
func (*Endpoint) GetValidAddress ¶
func (e *Endpoint) GetValidAddress() (WeightedAddress, bool)
GetValidAddress will return a non-expired weight endpoint
type EndpointCache ¶
type EndpointCache struct {
// contains filtered or unexported fields
}
EndpointCache is an LRU cache that holds a series of endpoints based on some key. The data structure makes use of a read write mutex to enable asynchronous use.
func NewEndpointCache ¶
func NewEndpointCache(endpointLimit int64) *EndpointCache
NewEndpointCache will return a newly initialized cache with a limit of endpointLimit entries.
func (*EndpointCache) Add ¶
func (c *EndpointCache) Add(endpoint Endpoint)
Add is a concurrent safe operation that will allow new endpoints to be added to the cache. If the cache is full, the number of endpoints equal endpointLimit, then this will remove the oldest entry before adding the new endpoint.
func (*EndpointCache) Get ¶
func (c *EndpointCache) Get(endpointKey string) (WeightedAddress, bool)
Get will retrieve a weighted address based off of the endpoint key. If an endpoint should be retrieved, due to not existing or the current endpoint has expired the Discoverer object that was passed in will attempt to discover a new endpoint and add that to the cache.
func (*EndpointCache) Has ¶
func (c *EndpointCache) Has(endpointKey string) bool
Has returns if the enpoint cache contains a valid entry for the endpoint key provided.
type WeightedAddress ¶
WeightedAddress represents an address with a given weight.
func (WeightedAddress) HasExpired ¶
func (e WeightedAddress) HasExpired() bool
HasExpired will return whether or not the endpoint has expired with the exception of a zero expiry meaning does not expire.
type WeightedAddresses ¶
type WeightedAddresses []WeightedAddress
WeightedAddresses represents a list of WeightedAddress.