consul

package
v0.0.0-...-8b2ef79 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DefaultWatchWaitTime is how long we will block when watching
	// for services or nodes to change/update
	DefaultWatchWaitTime = 15 * time.Second
)

Variables

View Source
var (
	// ErrMultipleEndpointsUnsupported is thrown when there are
	// multiple endpoints specified for Consul
	ErrMultipleEndpointsUnsupported = errors.New("consul does not support multiple endpoints")

	// ErrSessionRenew is thrown when the session can't be
	// renewed because the Consul version does not support sessions
	ErrSessionRenew = errors.New("cannot set or renew session for ttl, unable to operate on sessions")
)

Functions

func New

func New(endpoints []string, options *registry.Config) (registry.Registry, error)

New creates a new Consul client given a list of endpoints and optional tls config

func Register

func Register()

Register registers consul to libreg

Types

type Consul

type Consul struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Consul is the receiver type for the Store interface

func (*Consul) Datacenters

func (s *Consul) Datacenters() ([]string, error)

Datacenters lists known datacenters

func (*Consul) Deregister

func (s *Consul) Deregister(dereg *registry.CatalogDeregistration, options *registry.WriteOptions) error

Deregister removes a node, service or check

func (*Consul) Leader

func (s *Consul) Leader() (string, error)

Leader returns the cluster leader

func (*Consul) Node

func (s *Consul) Node(node string, options *registry.QueryOptions) (*registry.CatalogNode, error)

Node lists the services provided by a given node

func (*Consul) Nodes

func (s *Consul) Nodes(options *registry.QueryOptions) ([]*registry.Node, error)

Nodes lists all nodes in a given DC

func (*Consul) NodesWatch

func (s *Consul) NodesWatch(options *registry.QueryOptions, stopChan <-chan struct{}) (<-chan []*registry.Node, error)

NodesWatch watches for changes to the nodes in a given DC

func (*Consul) Register

func (s *Consul) Register(reg *registry.CatalogRegistration, options *registry.WriteOptions) error

Register adds an entry into the consul backend

func (*Consul) Service

func (s *Consul) Service(service, tag string, options *registry.QueryOptions) ([]*registry.CatalogService, error)

Service lists the nodes in a given service

func (*Consul) ServiceRegister

func (s *Consul) ServiceRegister(serv *registry.AgentServiceRegistration) error

ServiceRegister add a local agent service and its check

func (*Consul) ServiceWatch

func (s *Consul) ServiceWatch(service, tag string, options *registry.QueryOptions, stopChan <-chan struct{}) (<-chan []*registry.CatalogService, error)

ServiceWatch watches for changes to the list of nodes under a given service

func (*Consul) Services

func (s *Consul) Services(options *registry.QueryOptions) (map[string][]string, error)

Services lists all services in a given DC

func (*Consul) ServicesWatch

func (s *Consul) ServicesWatch(options *registry.QueryOptions, stopChan <-chan struct{}) (<-chan map[string][]string, error)

ServicesWatch watches for changes to the list of services in a given DC

Jump to

Keyboard shortcuts

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