Documentation ¶
Index ¶
- Variables
- func GetSRV(srvName, tag string) (string, int, error)
- func GetServiceHost(service, tag string) string
- func GetServicePort(service, tag string) (int, error)
- func NewConnection(settings ConsulSettings) error
- type Consul
- type ConsulSettings
- type Election
- type ElectionSettings
- type KVSettings
- type Locker
- type MKV
- type MasterWatcher
- type Semaphore
- type Service
- func (srvc *Service) AddHTTPcheck(name, path, interval string) error
- func (srvc *Service) AddJobCheck(name, interval string) error
- func (srvc *Service) AddTTLcheck(name, interval string) error
- func (srvc *Service) FailTTL()
- func (srvc *Service) GetHealthyOnes() ([]*api.ServiceEntry, error)
- func (srvc *Service) PassTTL()
- func (srvc *Service) Register() error
- func (srvc *Service) Remove() error
- func (srvc *Service) RemoveCheck(checkID string) error
- func (srvc *Service) StartKeepAlive(interval string) error
- func (srvc *Service) StopKeepAlvie()
- func (srvc *Service) StopWathing()
- func (srvc *Service) WarnTTL()
- func (srvc *Service) WatchService(w ServiceWatcher)
- type ServiceSettings
- type ServiceWatcher
- type Settings
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoServiceMatchesQuery means the query did not find any matches in Consul ErrNoServiceMatchesQuery = fmt.Errorf("No services match the query") // ErrServicePortNotUnique means there are diferent ports for the same service ErrServicePortNotUnique = fmt.Errorf("Service port is not unique!") )
View Source
var ErrConsulInvalidPath = errors.New("Consul invalid path")
ErrConsulInvalidPath happens when a given KV path is not present
Functions ¶
func GetServiceHost ¶
GetServiceHost returns the hostname of a given service
func GetServicePort ¶
GetServicePort returns the port associated with a given service
func NewConnection ¶
func NewConnection(settings ConsulSettings) error
Types ¶
type ConsulSettings ¶
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
func NewElection ¶
func NewElection(log *zap.Logger, settings ElectionSettings) (*Election, error)
func (*Election) NewCandidate ¶
func (*Election) StopWathing ¶
func (l *Election) StopWathing()
func (*Election) WatchMaster ¶
func (l *Election) WatchMaster(action MasterWatcher)
type ElectionSettings ¶
type KVSettings ¶
type KVSettings struct {
Path string
}
KVSettings is the configuration for the KV module
type MKV ¶
type MKV struct {
// contains filtered or unexported fields
}
MKV is a wrapper around consul's KV API
func NewKV ¶
func NewKV(log *zap.Logger, settings KVSettings) (*MKV, error)
NewKV returns a MKV object
type MasterWatcher ¶
type Semaphore ¶
Semaphore is an export of Consul's semaphore functionality
func NewResilientSemaphore ¶
NewResilientSemaphore constructs a semaphore that doesn't easily dies
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(log *zap.Logger, settings ServiceSettings) (*Service, error)
func (*Service) AddHTTPcheck ¶
func (*Service) AddJobCheck ¶
func (*Service) AddTTLcheck ¶
func (*Service) GetHealthyOnes ¶
func (srvc *Service) GetHealthyOnes() ([]*api.ServiceEntry, error)
func (*Service) RemoveCheck ¶
func (*Service) StartKeepAlive ¶
StartKeepAlive uses AddTTLcheck and automatically sends an ping to consul using an goroutine.
func (*Service) StopKeepAlvie ¶
func (srvc *Service) StopKeepAlvie()
func (*Service) StopWathing ¶
func (srvc *Service) StopWathing()
func (*Service) WatchService ¶
func (srvc *Service) WatchService(w ServiceWatcher)
type ServiceSettings ¶
type ServiceWatcher ¶
type ServiceWatcher interface { Health(si *api.ServiceEntry, err error) Fail(si *api.ServiceEntry, err error) }
type Settings ¶
type Settings struct { Consul *ConsulSettings `json:"consul"` Election *ElectionSettings `json:"election"` Service *ServiceSettings `json:"service"` KV *KVSettings `json:"kv"` }
Settings aggregates Service and Election settings
Click to show internal directories.
Click to hide internal directories.