consul-discovery: github.com/drnic/consul-discovery Index | Files | Directories

package consuldiscovery

import "github.com/drnic/consul-discovery"

* Package consuldiscovery is a client library to the Consul agent HTTP API for services and health checks. * If you require a client library for the key-value store, see https://github.com/armon/consul-kv

Index

Package Files

catalog.go client.go doc.go health.go status.go

type Catalog Uses

type Catalog interface {
    CatalogServices() CatalogServices
    CatalogServiceByName(name string) CatalogServiceByName
}

Catalog is a set of functions to find services information

type CatalogService Uses

type CatalogService struct {
    Name string
    Tags []string
}

CatalogService contains a single available service name and its tags

type CatalogServiceByName Uses

type CatalogServiceByName []CatalogServiceNode

CatalogServiceByName contains the nodes composing a service

type CatalogServiceNode Uses

type CatalogServiceNode struct {
    Node        string
    Address     string
    ServiceID   string
    ServiceName string
    ServiceTags []string
    ServicePort uint64
}

CatalogServiceNode describes a single node of a service From API response: {"Node":"drnic.local","Address":"192.168.50.1","ServiceID":"simple_service","ServiceName":"simple_service","ServiceTags":["tag1","tag2"],"ServicePort":6666}

type CatalogServices Uses

type CatalogServices []CatalogService

CatalogServices contains the available service names and their tags

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client provides a client to Consul for Service data

func NewClient Uses

func NewClient(config *Config) (*Client, error)

NewClient returns a new

func (*Client) CatalogServiceByName Uses

func (c *Client) CatalogServiceByName(name string) (nodes CatalogServiceByName, err error)

CatalogServiceByName returns a list of nodes composing a service

func (*Client) CatalogServices Uses

func (c *Client) CatalogServices() (result CatalogServices, err error)

CatalogServices returns a list of advertised service names and their tags

func (*Client) HealthByNode Uses

func (c *Client) HealthByNode(nodeName string) (result []HealthCheck, err error)

HealthByNode returns the health checks for a specific node

func (*Client) HealthByService Uses

func (c *Client) HealthByService(serviceName string) (result HealthNodes, err error)

HealthByService returns a list of advertised service names and their tags

func (*Client) HealthByState Uses

func (c *Client) HealthByState(state string) (checks []HealthCheck, err error)

HealthByState returns the health checks with a specific state

func (*Client) StatusLeader Uses

func (c *Client) StatusLeader() (leader string, err error)

StatusLeader gets the Raft leader for the datacenter

func (*Client) StatusPeers Uses

func (c *Client) StatusPeers() (peers []string, err error)

StatusPeers gets the Raft peers for the datacenter

type Config Uses

type Config struct {
    // Address is the address of the Consul server
    Address string

    // Datacenter to use. If not provided, the default agent datacenter is used.
    Datacenter string

    // HTTPClient is the client to use. Default will be
    // used if not provided.
    HTTPClient *http.Client

    // WaitTime limits how long a Watch will block. If not provided,
    // the agent default values will be used.
    WaitTime time.Duration

    // Debug shows HTTPClient responses if true
    Debug bool
}

Config is used to configure the creation of a client

func DefaultConfig Uses

func DefaultConfig() *Config

DefaultConfig returns a default configuration for the client

type Health Uses

type Health interface {
    HealthByNode(nodeName string) ([]HealthCheck, error)
    HealthByService(serviceName string) (HealthNodes, error)
    HealthByState(state string) ([]HealthCheck, error)
}

Health is a set of functions for the health of services

type HealthCheck Uses

type HealthCheck struct {
    Node        string
    CheckID     string
    Name        string
    Status      string
    Nodes       string
    Output      string
    ServiceID   string
    ServiceName string
}

HealthCheck contains a current health check result

type HealthForNode Uses

type HealthForNode struct {
    Node    HealthNode
    Service HealthService
    Checks  []HealthCheck
}

HealthForNode summarizes the health checks for a single Nodes for a single Service

type HealthNode Uses

type HealthNode struct {
    Node    string
    Address string
}

HealthNode indicates a server/node being described by HealthNodes

type HealthNodes Uses

type HealthNodes []HealthForNode

HealthNodes summarizes the health checks for all Nodes for a single Service

type HealthService Uses

type HealthService struct {
    ServiceID   string   `json:"ID"`
    ServiceName string   `json:"Service"`
    ServiceTags []string `json:"Tags"`
    ServicePort uint64   `json:"Port"`
}

HealthService indicates a service being described by HealthNodes

type Status Uses

type Status interface {
    StatusLeader() (string, error)
    StatusPeers() ([]string, error)
}

Status is a set of functions to get information about the status of the Consul cluster

Directories

PathSynopsis
examples

Package consuldiscovery imports 10 packages (graph) and is imported by 1 packages. Updated 2016-07-15. Refresh now. Tools for package owners.