consul

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package consul implements a GRPC resolver for consul service discovery. The resolver queries consul for healthy services with a specified name. Blocking Consul queries are used to monitor Consul for changes.

To register the resolver with the GRPC-Go library run:

resolver.Register(consul.NewBuilder())

Afterwards it can be used by calling google.golang.org/grpc.Dial and passing an URL in the following format:

consul://[<consul-server>]/<serviceName>[?<OPT>[&<OPT>]...]

OPT is one of:

  • scheme=http|https specifies if the connection to Consul is established via HTTP or HTTPS.
  • tags=<tag>[,<tag>]... only resolves to instances that have the given tags. Default: empty
  • health=healthy|fallbackToUnhealthy filters Services by their health status. If set to "healthy", the service is only resolved to instances with passing health checks. If set to "fallbackToUnhealthy", the service resolves to all instances, if none with a passing status is available. Default: healthy
  • token=<string> includes the token in API-Requests to Consul.

If an OPT is defined multiple times, only the value of the last occurrence is used.

The resolver can also be configured via the standard Consul Environment Variables. The supported environment variables and their defaults depend on the version of the github.com/hashicorp/consul/api package.

If consul-server, scheme or token is not specified in the URL, the settings defined via the Consul Environment Variables are used. If they are not defined, the defaults of the github.com/hashicorp/consul/api.NewClient are used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuilder

func NewBuilder() resolver.Builder

NewBuilder returns a builder for a consul resolver.

Types

This section is empty.

Jump to

Keyboard shortcuts

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