discovery

package
v0.0.0-...-f5938e8 Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	CheckForUpstreamChanges(backendName string, backendTag string) (bool, bool)
	CheckRegister(check *api.AgentCheckRegistration) error
	PassTTL(checkID, note string) error
	ServiceDeregister(serviceID string) error
	ServiceRegister(service *api.AgentServiceRegistration) error
}

Backend is an interface which all service discovery backends must implement

type ByServiceID

type ByServiceID []*api.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 {
	api.Client
	// contains filtered or unexported fields
}

Consul wraps the service discovery backend for the Hashicorp Consul client and tracks the state of all watched dependencies.

func NewConsul

func NewConsul(config interface{}) (*Consul, error)

NewConsul creates a new service discovery backend for Consul

func (*Consul) CheckForUpstreamChanges

func (c *Consul) CheckForUpstreamChanges(backendName, backendTag string) (didChange, isHealthy bool)

CheckForUpstreamChanges requests the set of healthy instances of a service from Consul and checks whether there has been a change since the last check.

func (*Consul) CheckRegister

func (c *Consul) CheckRegister(check *api.AgentCheckRegistration) error

CheckRegister wraps the Consul.Agent's CheckRegister method, is used to register a new service with the local agent

func (*Consul) PassTTL

func (c *Consul) PassTTL(name, note string) error

PassTTL wraps the Consul.Agent's PassTTL method, and is used to set a TTL check to the passing state

func (*Consul) ServiceDeregister

func (c *Consul) ServiceDeregister(serviceID string) error

ServiceDeregister wraps the Consul.Agent's ServiceDeregister method, and is used to deregister a service from the local agent

func (*Consul) ServiceRegister

func (c *Consul) ServiceRegister(service *api.AgentServiceRegistration) error

ServiceRegister wraps the Consul.Agent's ServiceRegister method, is used to register a new service with the local agent

type ServiceDefinition

type ServiceDefinition struct {
	ID                             string
	Name                           string
	Port                           int
	TTL                            int
	Tags                           []string
	IPAddress                      string
	EnableTagOverride              bool
	DeregisterCriticalServiceAfter string
	Consul                         Backend
	// contains filtered or unexported fields
}

ServiceDefinition is how a job communicates with the Consul service discovery backend.

func (*ServiceDefinition) Deregister

func (service *ServiceDefinition) Deregister()

Deregister removes the service from Consul.

func (*ServiceDefinition) MarkForMaintenance

func (service *ServiceDefinition) MarkForMaintenance()

MarkForMaintenance removes the service from Consul.

func (*ServiceDefinition) SendHeartbeat

func (service *ServiceDefinition) SendHeartbeat()

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.

Jump to

Keyboard shortcuts

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