Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster type exposes necessary methods to find master and slave from underlying store
func NewCluster ¶
NewCluster returns an new instance of Cluster
func (*Cluster) ServiceInfos ¶
func (c *Cluster) ServiceInfos() (ServiceInfos, error)
ServiceInfos returns all the service information from the cluster data in underlying store
type Config ¶
type Config struct { Backend string Endpoints string Token string TLSAddress string TLSCAFile string TLSCAPath string TLSCertFile string TLSKeyFile string TLSInsecureSkipVerify bool SleepInterval int TagMasterAs string TagSlaveAs string RegisterMaster bool }
Config represents necessary configurations which can passed for registering master and slave info for service discovery
func (*Config) ConsulConfig ¶
ConsulConfig returns consul.api.ConsulConfig if register endpoint is valid consul url else will return error with appropriate reason
type ConsulAgent ¶
type ConsulAgent interface { ServiceRegister(service *api.AgentServiceRegistration) error ServiceDeregister(serviceID string) error }
ConsulAgent interface holds all the necessary methods to interact with consul agent
type ConsulCatalog ¶
type ConsulCatalog interface {
Service(service, tag string, q *api.QueryOptions) ([]*api.CatalogService, *api.QueryMeta, error)
}
type ConsulServiceDiscovery ¶
type ConsulServiceDiscovery struct {
// contains filtered or unexported fields
}
ConsulServiceDiscovery helps to register service to consul
func (*ConsulServiceDiscovery) DeRegister ¶
func (cd *ConsulServiceDiscovery) DeRegister(info *ServiceInfo) error
DeRegister de-registers the given service info to consul
func (*ConsulServiceDiscovery) Register ¶
func (cd *ConsulServiceDiscovery) Register(info *ServiceInfo) error
Register registers the given service info to consul
func (*ConsulServiceDiscovery) Services ¶
func (cd *ConsulServiceDiscovery) Services(name string) (ServiceInfos, error)
Services returns the services registered in the consul
type HealthCheck ¶
HealthCheck holds necessary information for performing health check on the service
type ServiceDiscovery ¶
type ServiceDiscovery interface { Register(info *ServiceInfo) error Services(name string) (ServiceInfos, error) DeRegister(info *ServiceInfo) error }
ServiceDiscovery helps to register service
func NewConsulServiceDiscovery ¶
func NewConsulServiceDiscovery(agent ConsulAgent, catalog ConsulCatalog) ServiceDiscovery
NewConsulServiceDiscovery creates a new ConsulDiscovery
func NewServiceDiscovery ¶
func NewServiceDiscovery(config *Config) (ServiceDiscovery, error)
NewServiceDiscovery creates a Discovery from registerBackend and registerEndpoints
type ServiceInfo ¶
type ServiceInfo struct { Name string Tags Tags ID string Address string IsMaster bool Port int Check HealthCheck }
ServiceInfo holds the necessary information about a service for service discovery
func NewServiceInfo ¶
func NewServiceInfo(name string, db *cluster.DB, tags []string, isMaster bool) (*ServiceInfo, error)
NewServiceInfo return new ServiceInfo from name, db and tags
func NewServiceInfoFromConsulService ¶
func NewServiceInfoFromConsulService(service api.CatalogService) ServiceInfo
NewServiceInfoFromConsulService returns ServiceInfo from consul service
func (*ServiceInfo) Compare ¶
func (info *ServiceInfo) Compare(target ServiceInfo) bool
Compare if two ServiceInfo are equal
func (*ServiceInfo) ConsulAgentServiceRegistration ¶
func (info *ServiceInfo) ConsulAgentServiceRegistration() *api.AgentServiceRegistration
ConsulAgentServiceRegistration returns AgentServiceRegistration
type ServiceInfoStatus ¶
type ServiceInfoStatus struct { Added ServiceInfos Removed ServiceInfos }
ServiceInfoStatus holds the services which are newly added / removed
type ServiceInfos ¶
type ServiceInfos map[string]ServiceInfo
ServiceInfos represents holds collection of ServiceInfo
func (ServiceInfos) Diff ¶
func (existing ServiceInfos) Diff(discovered ServiceInfos) ServiceInfoStatus
Diff returns ServiceInfoStatus