Consul refactor
This commit is contained in:
parent
6dd11c6441
commit
5451899e48
@ -19,8 +19,8 @@ type Service struct {
|
|||||||
port int
|
port int
|
||||||
ttl time.Duration
|
ttl time.Duration
|
||||||
agent *consul.Agent
|
agent *consul.Agent
|
||||||
|
connect *consul.Connect
|
||||||
kv *consul.KV
|
kv *consul.KV
|
||||||
catalog *consul.Catalog
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
|
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
|
||||||
@ -40,8 +40,8 @@ func NewService(servAddr, id, name, hostname, domain, pathPrefix string, appPort
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.agent = client.Agent()
|
s.agent = client.Agent()
|
||||||
|
s.connect = client.Connect()
|
||||||
s.kv = client.KV()
|
s.kv = client.KV()
|
||||||
s.catalog = client.Catalog()
|
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
@ -103,12 +103,12 @@ func (s *Service) Unregister() error {
|
|||||||
return s.agent.ServiceDeregister(s.GetID())
|
return s.agent.ServiceDeregister(s.GetID())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) KV() *consul.KV {
|
func (s *Service) Connect() *consul.Connect {
|
||||||
return s.kv
|
return s.connect
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Catalog() *consul.Catalog {
|
func (s *Service) KV() *consul.KV {
|
||||||
return s.catalog
|
return s.kv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) healthCheck() (bool, error) {
|
func (s *Service) healthCheck() (bool, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user