Documentation ¶
Overview ¶
Package discovery manages the configuration of the Consul clients and the functions used to update/query Consul with service discovery data.
Index ¶
- type Backend
- type ByServiceID
- type Consul
- func (c *Consul) CheckForUpstreamChanges(backendName, backendTag, dc string) (didChange, isHealthy bool)
- func (c *Consul) CheckRegister(check *api.AgentCheckRegistration) error
- func (c *Consul) ServiceDeregister(serviceID string) error
- func (c *Consul) ServiceRegister(service *api.AgentServiceRegistration) error
- func (c *Consul) UpdateTTL(checkID, output, status string) error
- type ServiceDefinition
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { CheckForUpstreamChanges(service, tag, dc string) (bool, bool) CheckRegister(check *api.AgentCheckRegistration) error UpdateTTL(checkID, output, status 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 ¶
Consul wraps the service discovery backend for the Hashicorp Consul client and tracks the state of all watched dependencies.
func (*Consul) CheckForUpstreamChanges ¶
func (c *Consul) CheckForUpstreamChanges(backendName, backendTag, dc 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) ServiceDeregister ¶
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 InitialStatus 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) RegisterWithInitialStatus ¶
func (service *ServiceDefinition) RegisterWithInitialStatus()
RegisterWithInitialStatus registers the service with its configured initial status.
func (*ServiceDefinition) SendHeartbeat ¶
func (service *ServiceDefinition) SendHeartbeat() error
SendHeartbeat writes a TTL check status=ok to the Consul store.
type TestServer ¶
type TestServer struct { HTTPAddr string // contains filtered or unexported fields }
TestServer represents a Consul server we can run our tests against. Depends on a local `consul` binary installed into our environ's PATH.
func NewTestServer ¶
func NewTestServer(httpPort int) (*TestServer, error)
NewTestServer constructs a new TestServer by including the httpPort as well.
func (*TestServer) WaitForAPI ¶
func (s *TestServer) WaitForAPI() error
WaitForAPI waits for only the agent HTTP endpoint to start responding. This is an indication that the agent has started, but will likely return before a leader is elected.