Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d29bd0810b | |||
| b62c0e5a8c |
@@ -25,8 +25,8 @@ type Service struct {
|
|||||||
connect *connect.Service
|
connect *connect.Service
|
||||||
kv *consul.KV
|
kv *consul.KV
|
||||||
|
|
||||||
hcTicker *time.Ticker
|
// hcTicker *time.Ticker
|
||||||
ttlTicker *time.Ticker
|
// ttlTicker *time.Ticker
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
|
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
|
||||||
@@ -90,6 +90,8 @@ func (s *Service) Register() error {
|
|||||||
// DestinationServiceName: s.Name,
|
// DestinationServiceName: s.Name,
|
||||||
// },
|
// },
|
||||||
Check: &consul.AgentServiceCheck{
|
Check: &consul.AgentServiceCheck{
|
||||||
|
Interval: "5s",
|
||||||
|
Timeout: "1s",
|
||||||
TTL: s.ttl.String(),
|
TTL: s.ttl.String(),
|
||||||
Status: "passing",
|
Status: "passing",
|
||||||
DeregisterCriticalServiceAfter: "10s",
|
DeregisterCriticalServiceAfter: "10s",
|
||||||
@@ -162,14 +164,12 @@ func (s *Service) healthCheck() (bool, error) {
|
|||||||
// fmt.Printf("HealthCheck URL: %s%s?name=%s", s.GetFullAddr(), "health", s.Name)
|
// fmt.Printf("HealthCheck URL: %s%s?name=%s", s.GetFullAddr(), "health", s.Name)
|
||||||
req, err := http.NewRequest(http.MethodGet, healthUrl, nil)
|
req, err := http.NewRequest(http.MethodGet, healthUrl, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", "service/internal")
|
req.Header.Set("User-Agent", "service/internal")
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
@@ -177,8 +177,6 @@ func (s *Service) healthCheck() (bool, error) {
|
|||||||
var body []byte
|
var body []byte
|
||||||
resp.Body.Read(body)
|
resp.Body.Read(body)
|
||||||
|
|
||||||
fmt.Println(resp.StatusCode)
|
|
||||||
|
|
||||||
return resp.StatusCode == http.StatusOK
|
return resp.StatusCode == http.StatusOK
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user