Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultConsulAddr defaut consul addr DefaultConsulAddr = "http://127.0.0.1:8500" // DefaultCheckEndpoint default http check endpont DefaultCheckEndpoint = "/healthcheck" )
Variables ¶
This section is empty.
Functions ¶
func InitServiceDiscovery ¶
func InitServiceDiscovery(sdConfig *ServiceDiscoverySt, listenAddr string) (register SvcRegisteror, svc *SvcDef, err error)
InitServiceDiscovery init SD
Types ¶
type ConsulRegisteror ¶
type ConsulRegisteror struct {
// contains filtered or unexported fields
}
ConsulRegisteror implements service registeror backed by Consul
func NewConsulRegisteror ¶
func NewConsulRegisteror(addr string) *ConsulRegisteror
NewConsulRegisteror creates new ConsulRegisteror
func (ConsulRegisteror) Register ¶
func (r ConsulRegisteror) Register(svc *SvcDef) (interface{}, error)
Register implements method of SvcRegisteror
func (ConsulRegisteror) Unregister ¶
func (r ConsulRegisteror) Unregister(svc *SvcDef) (interface{}, error)
Unregister implements method of SvcRegisteror
type ServiceDiscoverySt ¶
type ServiceDiscoverySt struct { Type string `json:"type" yaml:"type"` RegAddr string `json:"regaddr" yaml:"regaddr"` SvcName string `json:"svcname" yaml:"svcname"` CheckEndpoint string `json:"check" yaml:"check"` CheckAddr string `json:"checkaddr" yaml:"checkaddr"` DiscoveryInfo string `json:"discinfo" yaml:"discinfo"` }
ServiceDiscoverySt defines config for consul discovery
type SvcDef ¶
type SvcDef struct { Name string ID string Addr string Port int Tags []string HealthCheck *SvcHealthChk }
SvcDef defines a service to register
type SvcHealthChk ¶
SvcHealthChk defines health check of a service
Click to show internal directories.
Click to hide internal directories.