kit: Index | Files

package consul

import ""

Package consul provides subscriber and registrar implementations for Consul.


Package Files

client.go doc.go registrar.go subscriber.go

type Client Uses

type Client interface {
    // Register a service with the local agent.
    Register(r *consul.AgentServiceRegistration) error

    // Deregister a service with the local agent.
    Deregister(r *consul.AgentServiceRegistration) error

    // Service
    Service(service, tag string, passingOnly bool, queryOpts *consul.QueryOptions) ([]*consul.ServiceEntry, *consul.QueryMeta, error)

Client is a wrapper around the Consul API.

func NewClient Uses

func NewClient(c *consul.Client) Client

NewClient returns an implementation of the Client interface, wrapping a concrete Consul client.

type Registrar Uses

type Registrar struct {
    // contains filtered or unexported fields

Registrar registers service instance liveness information to Consul.

func NewRegistrar Uses

func NewRegistrar(client Client, r *stdconsul.AgentServiceRegistration, logger log.Logger) *Registrar

NewRegistrar returns a Consul Registrar acting on the provided catalog registration.

func (*Registrar) Deregister Uses

func (p *Registrar) Deregister()

Deregister implements sd.Registrar interface.

func (*Registrar) Register Uses

func (p *Registrar) Register()

Register implements sd.Registrar interface.

type Subscriber Uses

type Subscriber struct {
    // contains filtered or unexported fields

Subscriber yields endpoints for a service in Consul. Updates to the service are watched and will update the Subscriber endpoints.

func NewSubscriber Uses

func NewSubscriber(client Client, factory sd.Factory, logger log.Logger, service string, tags []string, passingOnly bool) *Subscriber

NewSubscriber returns a Consul subscriber which returns endpoints for the requested service. It only returns instances for which all of the passed tags are present.

func (*Subscriber) Endpoints Uses

func (s *Subscriber) Endpoints() ([]endpoint.Endpoint, error)

Endpoints implements the Subscriber interface.

func (*Subscriber) Stop Uses

func (s *Subscriber) Stop()

Stop terminates the subscriber.

Package consul imports 7 packages (graph) and is imported by 6 packages. Updated 2017-03-07. Refresh now. Tools for package owners.