consul

package
v1.15.19 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const UpstreamNamePrefix = "consul-svc:"

Variables

View Source
var ForbiddenDataCenterErr = func(dataCenter string) error {
	return eris.Errorf("not allowed to query data center [%s]. "+
		"Use the settings to configure the data centers Gloo is allowed to query", dataCenter)
}

Functions

func CreateUpstreamsFromService added in v1.6.0

func CreateUpstreamsFromService(service *ServiceMeta, consulConfig *v1.Settings_ConsulUpstreamDiscoveryConfiguration) []*v1.Upstream

This function normally returns 1 upstream. It instead returns two upstreams if both automatic tls discovery and service-splitting is on for consul, and this service's tag list contains the tag specified by the tlsTagName config. In this case, it returns 2 upstreams that are identical save for the presence of the tlsTagName in the instanceTags array for the tls upstream, and the same value in the instanceBlacklistTags array for the non-tls upstream.

func DestinationToUpstreamRef

func DestinationToUpstreamRef(consulDest *v1.ConsulServiceDestination) *core.ResourceRef

func IsConsulUpstream

func IsConsulUpstream(upstreamName string) bool

func NewConsulCatalogServiceQueryOptions added in v1.9.25

func NewConsulCatalogServiceQueryOptions(dataCenter string, cm glooConsul.ConsulConsistencyModes, queryOptions *glooConsul.QueryOptions) *consulapi.QueryOptions

NewConsulCatalogServiceQueryOptions returns a QueryOptions configuration that's used for Consul queries to /catalog/service/:servicename

func NewConsulServicesQueryOptions added in v1.9.25

func NewConsulServicesQueryOptions(dataCenter string, cm glooConsul.ConsulConsistencyModes, _ *glooConsul.QueryOptions) *consulapi.QueryOptions

NewConsulServicesQueryOptions returns a QueryOptions configuration that's used for Consul queries to /catalog/services

func NewConsulUpstreamClient

func NewConsulUpstreamClient(consul ConsulWatcher, consulDiscoveryConfig *v1.Settings_ConsulUpstreamDiscoveryConfiguration) v1.UpstreamClient

This client can list and watch Consul services. A Gloo upstream will be generated for each unique Consul service name. The Consul EDS will discover and characterize all endpoints for each one of these upstreams across the available data centers.

NOTE: any method except List and Watch will panic!

Types

type ClientWrapper added in v1.9.25

type ClientWrapper interface {
	// DataCenters is used to query for all the known data centers.
	// Results will be filtered based on the data center whitelist provided in the Gloo settings.
	DataCenters() ([]string, error)
	// Services is used to query for all known services
	Services(q *consulapi.QueryOptions) (map[string][]string, *consulapi.QueryMeta, error)
	// Service is used to query catalog entries for a given service
	Service(service, tag string, q *consulapi.QueryOptions) ([]*consulapi.CatalogService, *consulapi.QueryMeta, error)
	// Connect is used to query catalog entries for a given Connect-enabled service
	Connect(service, tag string, q *consulapi.QueryOptions) ([]*consulapi.CatalogService, *consulapi.QueryMeta, error)
}

TODO(marco): consider adding ctx to signatures instead on relying on caller to set it Wrap the Consul API in an interface to allow mocking

func NewConsulClientWrapper added in v1.9.25

func NewConsulClientWrapper(consulClient *consulapi.Client) ClientWrapper

NewConsulClientWrapper wraps the original consul client to allow for access in testing + simplification of calls

func NewFilteredConsulClient added in v1.9.25

func NewFilteredConsulClient(client ClientWrapper, dataCenters []string, serviceTagsAllowlist []string) (ClientWrapper, error)

NewFilteredConsulClient is used to create a new client for filtered consul requests. We have a wrapper around the consul api client *consulapi.Client - so that we can filter requests

type ConsulWatcher

type ConsulWatcher interface {
	ClientWrapper
	WatchServices(ctx context.Context, dataCenters []string, cm glooconsul.ConsulConsistencyModes, queryOpts *glooconsul.QueryOptions) (<-chan []*ServiceMeta, <-chan error)
}

func NewConsulWatcher

func NewConsulWatcher(client *consulapi.Client, dataCenters []string, serviceTagsAllowlist []string) (ConsulWatcher, error)

func NewConsulWatcherFromClient

func NewConsulWatcherFromClient(client ClientWrapper) ConsulWatcher

type ServiceMeta

type ServiceMeta struct {
	Name        string
	DataCenters []string
	Tags        []string
}

Data for a single consul service (not serviceInstance)

Directories

Path Synopsis
Package mock_consul is a generated GoMock package.
Package mock_consul is a generated GoMock package.

Jump to

Keyboard shortcuts

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