Documentation
¶
Overview ¶
Package resolver contains logic to perform per `transaction.Endpoint` domain resolution. The idea behind this package is to allow the forwarder to send some data to a given domain and other kinds of data to other domains based on the targeted `transaction.Endpoint`.
Index ¶
- func NewSingleDomainResolvers(keysPerDomain map[string][]utils.APIKeys) (map[string]DomainResolver, error)
- func OnUpdateConfig(resolver DomainResolver, log log.Component, config config.Component)
- type DestinationType
- type DomainResolver
- type ForwarderHealth
- type LocalDomainResolver
- func (r *LocalDomainResolver) GetAPIKeyVersion() int
- func (r *LocalDomainResolver) GetAPIKeys() []string
- func (r *LocalDomainResolver) GetAPIKeysInfo() ([]utils.APIKeys, int)
- func (r *LocalDomainResolver) GetAlternateDomains() []string
- func (r *LocalDomainResolver) GetBaseDomain() string
- func (r *LocalDomainResolver) GetBearerAuthToken() string
- func (r *LocalDomainResolver) GetForwarderHealth() ForwarderHealth
- func (r *LocalDomainResolver) Resolve(transaction.Endpoint) (string, DestinationType)
- func (r *LocalDomainResolver) SetBaseDomain(domain string)
- func (r *LocalDomainResolver) SetForwarderHealth(_ ForwarderHealth)
- func (r *LocalDomainResolver) UpdateAPIKey(_, _, _ string)
- func (r *LocalDomainResolver) UpdateAPIKeys(_ string, _ []utils.APIKeys)
- type MultiDomainResolver
- func (r *MultiDomainResolver) GetAPIKeyVersion() int
- func (r *MultiDomainResolver) GetAPIKeys() []string
- func (r *MultiDomainResolver) GetAPIKeysInfo() ([]utils.APIKeys, int)
- func (r *MultiDomainResolver) GetAlternateDomains() []string
- func (r *MultiDomainResolver) GetBaseDomain() string
- func (r *MultiDomainResolver) GetBearerAuthToken() string
- func (r *MultiDomainResolver) GetForwarderHealth() ForwarderHealth
- func (r *MultiDomainResolver) RegisterAlternateDestination(domain string, forwarderName string, dType DestinationType)
- func (r *MultiDomainResolver) Resolve(endpoint transaction.Endpoint) (string, DestinationType)
- func (r *MultiDomainResolver) SetBaseDomain(domain string)
- func (r *MultiDomainResolver) SetForwarderHealth(healthChecker ForwarderHealth)
- func (r *MultiDomainResolver) UpdateAPIKey(configPath, oldKey, newKey string)
- func (r *MultiDomainResolver) UpdateAPIKeys(configPath string, newKeys []utils.APIKeys)
- type SingleDomainResolver
- func (r *SingleDomainResolver) GetAPIKeyVersion() int
- func (r *SingleDomainResolver) GetAPIKeys() []string
- func (r *SingleDomainResolver) GetAPIKeysInfo() ([]utils.APIKeys, int)
- func (r *SingleDomainResolver) GetAlternateDomains() []string
- func (r *SingleDomainResolver) GetBaseDomain() string
- func (r *SingleDomainResolver) GetBearerAuthToken() string
- func (r *SingleDomainResolver) GetForwarderHealth() ForwarderHealth
- func (r *SingleDomainResolver) Resolve(transaction.Endpoint) (string, DestinationType)
- func (r *SingleDomainResolver) SetBaseDomain(domain string)
- func (r *SingleDomainResolver) SetForwarderHealth(healthChecker ForwarderHealth)
- func (r *SingleDomainResolver) UpdateAPIKey(configPath, oldKey, newKey string)
- func (r *SingleDomainResolver) UpdateAPIKeys(configPath string, newKeys []utils.APIKeys)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSingleDomainResolvers ¶
func NewSingleDomainResolvers(keysPerDomain map[string][]utils.APIKeys) (map[string]DomainResolver, error)
NewSingleDomainResolvers converts a map of domain/api keys into a map of SingleDomainResolver
func OnUpdateConfig ¶ added in v0.66.0
func OnUpdateConfig(resolver DomainResolver, log log.Component, config config.Component)
OnUpdateConfig adds a hook into the config which will listen for updates to the API keys of the resolver.
Types ¶
type DestinationType ¶
type DestinationType int
DestinationType is used to identified the expected endpoint
const ( // Datadog enpoints Datadog DestinationType = iota // Vector endpoints Vector // Local endpoints Local )
type DomainResolver ¶
type DomainResolver interface {
// Resolve returns the domain to be used to send data for a given `transaction.Endpoint` along with a
// destination type
Resolve(endpoint transaction.Endpoint) (string, DestinationType)
// GetAPIKeysInfo returns the list of API Keys and config paths associated with this `DomainResolver`
GetAPIKeysInfo() ([]utils.APIKeys, int)
// GetAPIKeys returns the list of API Keys associated with this `DomainResolver`
GetAPIKeys() []string
// UpdateAPIKeys updates the api keys at the given config path and sets the deduped keys to the new list.
UpdateAPIKeys(configPath string, newKeys []utils.APIKeys)
// GetAPIKeyVersion gets the current version for the API keys (version should be incremented each time the
// keys are updated).
GetAPIKeyVersion() int
// GetBaseDomain returns the base domain for this `DomainResolver`
GetBaseDomain() string
// GetAlternateDomains returns all the domains that can be returned by `Resolve()` minus the base domain
GetAlternateDomains() []string
// SetBaseDomain sets the base domain to a new value
SetBaseDomain(domain string)
// UpdateAPIKey replaces instances of the oldKey with the newKey
UpdateAPIKey(configPath, oldKey, newKey string)
// GetBearerAuthToken returns Bearer authtoken, used for internal communication
GetBearerAuthToken() string
// GetForwarderHealth returns the health checker
GetForwarderHealth() ForwarderHealth
// SetForwarderHealth sets the health checker for this domain
// Needed so we update the health checker when API keys are updated
SetForwarderHealth(ForwarderHealth)
}
DomainResolver interface abstracts domain selection by `transaction.Endpoint`
type ForwarderHealth ¶ added in v0.67.0
ForwarderHealth interface is implemented by the health checker. The resolver uses this method to inform the healthchecker when API keys have been updated.
type LocalDomainResolver ¶ added in v0.60.0
type LocalDomainResolver struct {
// contains filtered or unexported fields
}
LocalDomainResolver contains domain address in local cluster and authToken for internal communication
func NewLocalDomainResolver ¶ added in v0.60.0
func NewLocalDomainResolver(domain string, authToken string) *LocalDomainResolver
NewLocalDomainResolver creates a LocalDomainResolver with domain in local cluster and authToken for internal communication For example, the internal cluster-agent endpoint
func (*LocalDomainResolver) GetAPIKeyVersion ¶ added in v0.67.0
func (r *LocalDomainResolver) GetAPIKeyVersion() int
GetAPIKeyVersion get the version of the keys
func (*LocalDomainResolver) GetAPIKeys ¶ added in v0.60.0
func (r *LocalDomainResolver) GetAPIKeys() []string
GetAPIKeys is not implemented for LocalDomainResolver
func (*LocalDomainResolver) GetAPIKeysInfo ¶ added in v0.66.0
func (r *LocalDomainResolver) GetAPIKeysInfo() ([]utils.APIKeys, int)
GetAPIKeysInfo returns the list of endpoints associated with this `DomainResolver`
func (*LocalDomainResolver) GetAlternateDomains ¶ added in v0.60.0
func (r *LocalDomainResolver) GetAlternateDomains() []string
GetAlternateDomains is not implemented for LocalDomainResolver
func (*LocalDomainResolver) GetBaseDomain ¶ added in v0.60.0
func (r *LocalDomainResolver) GetBaseDomain() string
GetBaseDomain returns the base domain for this LocalDomainResolver
func (*LocalDomainResolver) GetBearerAuthToken ¶ added in v0.60.0
func (r *LocalDomainResolver) GetBearerAuthToken() string
GetBearerAuthToken returns Bearer authtoken, used for internal communication
func (*LocalDomainResolver) GetForwarderHealth ¶ added in v0.67.0
func (r *LocalDomainResolver) GetForwarderHealth() ForwarderHealth
GetForwarderHealth returns the health checker Not used for LocalDomainResolver
func (*LocalDomainResolver) Resolve ¶ added in v0.60.0
func (r *LocalDomainResolver) Resolve(transaction.Endpoint) (string, DestinationType)
Resolve returns the domain to be used to send data and local destination type
func (*LocalDomainResolver) SetBaseDomain ¶ added in v0.60.0
func (r *LocalDomainResolver) SetBaseDomain(domain string)
SetBaseDomain sets the base domain to a new value
func (*LocalDomainResolver) SetForwarderHealth ¶ added in v0.67.0
func (r *LocalDomainResolver) SetForwarderHealth(_ ForwarderHealth)
SetForwarderHealth sets the health checker for this domain Not used for LocalDomainResolver
func (*LocalDomainResolver) UpdateAPIKey ¶ added in v0.60.0
func (r *LocalDomainResolver) UpdateAPIKey(_, _, _ string)
UpdateAPIKey is not implemented for LocalDomainResolver
func (*LocalDomainResolver) UpdateAPIKeys ¶ added in v0.66.0
func (r *LocalDomainResolver) UpdateAPIKeys(_ string, _ []utils.APIKeys)
UpdateAPIKeys is not implemented for LocalDomainResolver
type MultiDomainResolver ¶
type MultiDomainResolver struct {
// contains filtered or unexported fields
}
MultiDomainResolver holds a default value and can provide alternate domain for some route
func NewDomainResolverWithMetricToVector ¶
func NewDomainResolverWithMetricToVector(mainEndpoint string, apiKeys []utils.APIKeys, vectorEndpoint string) (*MultiDomainResolver, error)
NewDomainResolverWithMetricToVector initialize a resolver with metrics diverted to a vector endpoint
func NewMultiDomainResolver ¶
func NewMultiDomainResolver(baseDomain string, apiKeys []utils.APIKeys) (*MultiDomainResolver, error)
NewMultiDomainResolver initializes a MultiDomainResolver with its API keys and base destination
func (*MultiDomainResolver) GetAPIKeyVersion ¶ added in v0.67.0
func (r *MultiDomainResolver) GetAPIKeyVersion() int
GetAPIKeyVersion get the version of the keys
func (*MultiDomainResolver) GetAPIKeys ¶
func (r *MultiDomainResolver) GetAPIKeys() []string
GetAPIKeys returns the slice of API keys associated with this SingleDomainResolver
func (*MultiDomainResolver) GetAPIKeysInfo ¶ added in v0.66.0
func (r *MultiDomainResolver) GetAPIKeysInfo() ([]utils.APIKeys, int)
GetAPIKeysInfo returns the list of endpoints associated with this `DomainResolver`
func (*MultiDomainResolver) GetAlternateDomains ¶
func (r *MultiDomainResolver) GetAlternateDomains() []string
GetAlternateDomains returns a slice with all alternate domain
func (*MultiDomainResolver) GetBaseDomain ¶
func (r *MultiDomainResolver) GetBaseDomain() string
GetBaseDomain returns the base domain
func (*MultiDomainResolver) GetBearerAuthToken ¶ added in v0.60.0
func (r *MultiDomainResolver) GetBearerAuthToken() string
GetBearerAuthToken is not implemented for MultiDomainResolver
func (*MultiDomainResolver) GetForwarderHealth ¶ added in v0.67.0
func (r *MultiDomainResolver) GetForwarderHealth() ForwarderHealth
GetForwarderHealth returns the health checker
func (*MultiDomainResolver) RegisterAlternateDestination ¶
func (r *MultiDomainResolver) RegisterAlternateDestination(domain string, forwarderName string, dType DestinationType)
RegisterAlternateDestination adds an alternate destination to a MultiDomainResolver. The resolver will match transaction.Endpoint.Name against forwarderName to check if the request shall be diverted.
func (*MultiDomainResolver) Resolve ¶
func (r *MultiDomainResolver) Resolve(endpoint transaction.Endpoint) (string, DestinationType)
Resolve returns the destiation for a given request endpoint
func (*MultiDomainResolver) SetBaseDomain ¶
func (r *MultiDomainResolver) SetBaseDomain(domain string)
SetBaseDomain updates the base domain
func (*MultiDomainResolver) SetForwarderHealth ¶ added in v0.67.0
func (r *MultiDomainResolver) SetForwarderHealth(healthChecker ForwarderHealth)
SetForwarderHealth sets the health checker for this domain Needed so we update the health checker when API keys are updated
func (*MultiDomainResolver) UpdateAPIKey ¶ added in v0.53.0
func (r *MultiDomainResolver) UpdateAPIKey(configPath, oldKey, newKey string)
UpdateAPIKey replaces instances of the oldKey with the newKey
func (*MultiDomainResolver) UpdateAPIKeys ¶ added in v0.66.0
func (r *MultiDomainResolver) UpdateAPIKeys(configPath string, newKeys []utils.APIKeys)
UpdateAPIKeys updates the api keys at the given config path and sets the deduped keys to the new list.
type SingleDomainResolver ¶
type SingleDomainResolver struct {
// contains filtered or unexported fields
}
SingleDomainResolver will always return the same host
func NewSingleDomainResolver ¶
func NewSingleDomainResolver(domain string, apiKeys []utils.APIKeys) (*SingleDomainResolver, error)
NewSingleDomainResolver creates a SingleDomainResolver with its destination domain & API keys
func (*SingleDomainResolver) GetAPIKeyVersion ¶ added in v0.67.0
func (r *SingleDomainResolver) GetAPIKeyVersion() int
GetAPIKeyVersion get the version of the keys.
func (*SingleDomainResolver) GetAPIKeys ¶
func (r *SingleDomainResolver) GetAPIKeys() []string
GetAPIKeys returns the slice of API keys associated with this SingleDomainResolver
func (*SingleDomainResolver) GetAPIKeysInfo ¶ added in v0.66.0
func (r *SingleDomainResolver) GetAPIKeysInfo() ([]utils.APIKeys, int)
GetAPIKeysInfo returns the list of APIKeys and config paths associated with this `DomainResolver`
func (*SingleDomainResolver) GetAlternateDomains ¶
func (r *SingleDomainResolver) GetAlternateDomains() []string
GetAlternateDomains always returns an empty slice for SingleDomainResolver
func (*SingleDomainResolver) GetBaseDomain ¶
func (r *SingleDomainResolver) GetBaseDomain() string
GetBaseDomain returns the only destination available for a SingleDomainResolver
func (*SingleDomainResolver) GetBearerAuthToken ¶ added in v0.60.0
func (r *SingleDomainResolver) GetBearerAuthToken() string
GetBearerAuthToken is not implemented for SingleDomainResolver
func (*SingleDomainResolver) GetForwarderHealth ¶ added in v0.67.0
func (r *SingleDomainResolver) GetForwarderHealth() ForwarderHealth
GetForwarderHealth returns the health checker
func (*SingleDomainResolver) Resolve ¶
func (r *SingleDomainResolver) Resolve(transaction.Endpoint) (string, DestinationType)
Resolve always returns the only destination available for a SingleDomainResolver
func (*SingleDomainResolver) SetBaseDomain ¶
func (r *SingleDomainResolver) SetBaseDomain(domain string)
SetBaseDomain sets the only destination available for a SingleDomainResolver
func (*SingleDomainResolver) SetForwarderHealth ¶ added in v0.67.0
func (r *SingleDomainResolver) SetForwarderHealth(healthChecker ForwarderHealth)
SetForwarderHealth sets the health checker for this domain Needed so we update the health checker when API keys are updated
func (*SingleDomainResolver) UpdateAPIKey ¶ added in v0.53.0
func (r *SingleDomainResolver) UpdateAPIKey(configPath, oldKey, newKey string)
UpdateAPIKey replaces instances of the oldKey with the newKey
func (*SingleDomainResolver) UpdateAPIKeys ¶ added in v0.66.0
func (r *SingleDomainResolver) UpdateAPIKeys(configPath string, newKeys []utils.APIKeys)
UpdateAPIKeys updates the api keys at the given config path and sets the deduped keys to the new list.