Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEndpointKey ¶
BuildEndpointKey will sort the keys in alphabetical order and then retrieve the values in that order. Those values are then concatenated together to form the endpoint key.
Types ¶
type Discoverer ¶
Discoverer is an interface used to discovery which endpoint hit. This allows for specifics about what parameters need to be used to be contained in the Discoverer implementor.
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 datastructure 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(d Discoverer, endpointKey string, required bool) (WeightedAddress, error)
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 ¶ added in v1.15.83
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.