proxy

package
v1.9.13 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MPL-2.0 Imports: 18 Imported by: 41

Documentation

Index

Constants

View Source
const (
	// RegisterReconcilePeriod is how often the monitor will attempt to
	// reconcile the expected service state with the remote Consul server.
	RegisterReconcilePeriod = 30 * time.Second

	// RegisterTTLPeriod is the TTL setting for the health check of the
	// service. The monitor will automatically pass the health check
	// three times per this period to be more resilient to failures.
	RegisterTTLPeriod = 30 * time.Second
)

Variables

This section is empty.

Functions

func LookupGatewayProxy added in v1.6.0

func LookupGatewayProxy(client *api.Client, kind api.ServiceKind) (*api.AgentService, error)

LookupGatewayProxy finds the gateway service registered with the local agent. If exactly one gateway exists it will be returned, otherwise an error is returned.

func LookupProxyIDForSidecar added in v1.3.0

func LookupProxyIDForSidecar(client *api.Client, sidecarFor string) (string, error)

LookupProxyIDForSidecar finds candidate local proxy registrations that are a sidecar for the given service. It will return an ID if and only if there is exactly one registered connect proxy with `Proxy.DestinationServiceID` set to the specified service ID.

This is exported to share it with the connect envoy command.

func New

func New(ui cli.Ui, shutdownCh <-chan struct{}) *cmd

Types

type FlagUpstreams

type FlagUpstreams map[string]proxy.UpstreamConfig

FlagUpstreams implements the flag.Value interface and allows specifying the -upstream flag multiple times and keeping track of the name of the upstream and the local port.

The syntax of the value is "name:addr" where addr can be "port" or "host:port". Examples: "db:8181", "db:127.0.0.10:8282", etc.

func (*FlagUpstreams) Set

func (f *FlagUpstreams) Set(value string) error

func (*FlagUpstreams) String

func (f *FlagUpstreams) String() string

type RegisterMonitor

type RegisterMonitor struct {
	// Logger is the logger for the monitor.
	Logger hclog.Logger

	// Client is the API client to a specific Consul agent. This agent is
	// where the service will be registered.
	Client *api.Client

	// Service is the name of the service being proxied.
	Service string

	// LocalAddress and LocalPort are the address and port of the proxy
	// itself, NOT the service being proxied.
	LocalAddress string
	LocalPort    int

	// IDSuffix is a unique ID that is appended to the end of the service
	// name. This helps the service be unique. By default the service ID
	// is just the proxied service name followed by "-proxy".
	IDSuffix string

	// The fields below are related to timing settings. See the default
	// constants for more documentation on what they set.
	ReconcilePeriod time.Duration
	TTLPeriod       time.Duration
	// contains filtered or unexported fields
}

RegisterMonitor registers the proxy with the local Consul agent with a TTL health check that is kept alive.

This struct should be initialized with NewRegisterMonitor instead of being allocated directly. Using this struct without calling NewRegisterMonitor will result in panics.

func NewRegisterMonitor

func NewRegisterMonitor(logger hclog.Logger) *RegisterMonitor

NewRegisterMonitor initializes a RegisterMonitor. After initialization, the exported fields should be configured as desired. To start the monitor, execute Run in a goroutine.

func (*RegisterMonitor) Close

func (r *RegisterMonitor) Close() error

Close stops the register goroutines and deregisters the service. Once Close is called, the monitor can no longer be used again. It is safe to call Close multiple times and concurrently.

func (*RegisterMonitor) Run

func (r *RegisterMonitor) Run()

Run should be started in a goroutine and will keep Consul updated in the background with the state of this proxy. If registration fails this will continue to retry.

Jump to

Keyboard shortcuts

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