discovery

package
v0.0.0-...-cea9070 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByEtcdServiceID

type ByEtcdServiceID []EtcdServiceNode

ByEtcdServiceID implements the Sort interface because Go can't sort without it.

func (ByEtcdServiceID) Len

func (se ByEtcdServiceID) Len() int

func (ByEtcdServiceID) Less

func (se ByEtcdServiceID) Less(i, j int) bool

func (ByEtcdServiceID) Swap

func (se ByEtcdServiceID) Swap(i, j int)

type ByServiceID

type ByServiceID []*consul.ServiceEntry

ByServiceID implements the Sort interface because Go can't sort without it.

func (ByServiceID) Len

func (se ByServiceID) Len() int

func (ByServiceID) Less

func (se ByServiceID) Less(i, j int) bool

func (ByServiceID) Swap

func (se ByServiceID) Swap(i, j int)

type Consul

type Consul struct{ consul.Client }

Consul is a service discovery backend for Hashicorp Consul

func NewConsulConfig

func NewConsulConfig(uri string) Consul

NewConsulConfig creates a new service discovery backend for Consul

func (Consul) CheckForUpstreamChanges

func (c Consul) CheckForUpstreamChanges(backendName, backendTag string) bool

CheckForUpstreamChanges runs the health check

func (Consul) Deregister

func (c Consul) Deregister(service *ServiceDefinition)

Deregister removes the node from Consul.

func (Consul) MarkForMaintenance

func (c Consul) MarkForMaintenance(service *ServiceDefinition)

MarkForMaintenance removes the node from Consul.

func (Consul) SendHeartbeat

func (c Consul) SendHeartbeat(service *ServiceDefinition)

SendHeartbeat writes a TTL check status=ok to the consul store. If consul has never seen this service, we register the service and its TTL check.

type DiscoveryService

type DiscoveryService interface {
	SendHeartbeat(service *ServiceDefinition)
	CheckForUpstreamChanges(backendName string, backendTag string) bool
	MarkForMaintenance(service *ServiceDefinition)
	Deregister(service *ServiceDefinition)
}

DiscoveryService is an interface which all service discovery backends must implement

type Etcd

type Etcd struct {
	Client client.Client
	API    client.KeysAPI
	Prefix string
}

Etcd is a service discovery backend for CoreOS etcd

func NewEtcdConfig

func NewEtcdConfig(config json.RawMessage) Etcd

NewEtcdConfig creates a new service discovery backend for etcd

func (Etcd) CheckForUpstreamChanges

func (c Etcd) CheckForUpstreamChanges(backendName, backendTag string) bool

CheckForUpstreamChanges checks another etcd node for changes

func (Etcd) Deregister

func (c Etcd) Deregister(service *ServiceDefinition)

Deregister removes this instance from the registry

func (Etcd) MarkForMaintenance

func (c Etcd) MarkForMaintenance(service *ServiceDefinition)

MarkForMaintenance removes this instance from the registry

func (Etcd) SendHeartbeat

func (c Etcd) SendHeartbeat(service *ServiceDefinition)

SendHeartbeat refreshes the TTL of this associated etcd node

type EtcdServiceNode

type EtcdServiceNode struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Address string   `json:"address"`
	Port    int      `json:"port"`
	Tags    []string `json:"tags,omitempty"`
}

EtcdServiceNode is an instance of a service

type ServiceDefinition

type ServiceDefinition struct {
	ID        string
	Name      string
	Port      int
	TTL       int
	Tags      []string
	IpAddress string
}

Jump to

Keyboard shortcuts

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