Compare commits

...

5 Commits

Author SHA1 Message Date
2c797164e0 consul registration update 2024-07-21 21:00:49 +02:00
7725e5dd65 debug fix 2024-07-20 20:12:29 +02:00
07c0cd6f2e debug fix 2024-07-20 19:59:12 +02:00
d29bd0810b debug fix 2024-07-20 19:55:33 +02:00
b62c0e5a8c debug fix 2024-07-20 19:03:21 +02:00

View File

@@ -25,8 +25,8 @@ type Service struct {
connect *connect.Service
kv *consul.KV
hcTicker *time.Ticker
ttlTicker *time.Ticker
// hcTicker *time.Ticker
// ttlTicker *time.Ticker
}
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
@@ -85,11 +85,13 @@ func (s *Service) Register() error {
Address: s.Address,
Port: s.port,
Tags: s.getTags(),
// Connect: &consul.AgentServiceConnect{Native: true},
Connect: &consul.AgentServiceConnect{Native: true},
// Proxy: &consul.AgentServiceConnectProxyConfig{
// DestinationServiceName: s.Name,
// },
Check: &consul.AgentServiceCheck{
// Interval: "5s",
// Timeout: "1s",
TTL: s.ttl.String(),
Status: "passing",
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)
req, err := http.NewRequest(http.MethodGet, healthUrl, nil)
if err != nil {
fmt.Println(err)
return false
}
req.Header.Set("User-Agent", "service/internal")
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return false
}
defer resp.Body.Close()
@@ -177,8 +177,6 @@ func (s *Service) healthCheck() (bool, error) {
var body []byte
resp.Body.Read(body)
fmt.Println(resp.StatusCode)
return resp.StatusCode == http.StatusOK
}()