package consul
import "github.com/go-kit/kit/sd/consul"
Package consul provides Instancer and Registrar implementations for Consul.
Index ¶
- type Client
- type Instancer
- func NewInstancer(client Client, logger log.Logger, service string, tags []string, passingOnly bool) *Instancer
- func (s *Instancer) Deregister(ch chan<- sd.Event)
- func (s *Instancer) Register(ch chan<- sd.Event)
- func (s *Instancer) Stop()
- type Registrar
Types ¶
type Client ¶
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 ¶
NewClient returns an implementation of the Client interface, wrapping a concrete Consul client.
type Instancer ¶
type Instancer struct {
// contains filtered or unexported fields
}
Instancer yields instances for a service in Consul.
func NewInstancer ¶
func NewInstancer(client Client, logger log.Logger, service string, tags []string, passingOnly bool) *Instancer
NewInstancer returns a Consul instancer that publishes instances for the requested service. It only returns instances for which all of the passed tags are present.
func (*Instancer) Deregister ¶
Deregister implements Instancer.
func (*Instancer) Register ¶
Register implements Instancer.
func (*Instancer) Stop ¶
func (s *Instancer) Stop()
Stop terminates the instancer.
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar registers service instance liveness information to Consul.
func NewRegistrar ¶
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 ¶
func (p *Registrar) Deregister()
Deregister implements sd.Registrar interface.
func (*Registrar) Register ¶
func (p *Registrar) Register()
Register implements sd.Registrar interface.
Source Files ¶
client.go doc.go instancer.go registrar.go
- Version
- v0.13.0 (latest)
- Published
- May 29, 2023
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 1 day ago –
Tools for package owners.