resolver

package
v0.0.0-...-44638ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSingleDomainResolvers

func NewSingleDomainResolvers(keysPerDomain map[string][]string) map[string]DomainResolver

NewSingleDomainResolvers converts a map of domain/api keys into a map of SingleDomainResolver

Types

type DestinationType

type DestinationType int

DestinationType is used to identified the expected endpoint

const (
	// Datadog enpoints
	Datadog DestinationType = iota
	// Vector endpoints
	Vector
)

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)
	// GetAPIKeys returns the list of API Keys associated with this `DomainResolver`
	GetAPIKeys() []string
	// 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)
}

DomainResolver interface abstracts domain selection by `transaction.Endpoint`

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 []string, vectorEndpoint string) *MultiDomainResolver

NewDomainResolverWithMetricToVector initialize a resolver with metrics diverted to a vector endpoint

func NewMultiDomainResolver

func NewMultiDomainResolver(baseDomain string, apiKeys []string) *MultiDomainResolver

NewMultiDomainResolver initializes a MultiDomainResolver with its API keys and base destination

func (*MultiDomainResolver) GetAPIKeys

func (r *MultiDomainResolver) GetAPIKeys() []string

GetAPIKeys returns the slice of API keys associated with this SingleDomainResolver

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) 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

Resolve returns the destiation for a given request endpoint

func (*MultiDomainResolver) SetBaseDomain

func (r *MultiDomainResolver) SetBaseDomain(domain string)

SetBaseDomain updates the base domain

type SingleDomainResolver

type SingleDomainResolver struct {
	// contains filtered or unexported fields
}

SingleDomainResolver will always return the same host

func NewSingleDomainResolver

func NewSingleDomainResolver(domain string, apiKeys []string) *SingleDomainResolver

NewSingleDomainResolver creates a SingleDomainResolver with its destination domain & API keys

func (*SingleDomainResolver) GetAPIKeys

func (r *SingleDomainResolver) GetAPIKeys() []string

GetAPIKeys returns the slice of API keys associated with this SingleDomainResolver

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) Resolve

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL