only check nats if it is used
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
Bugfix: fix gateway nats checks
|
||||||
|
|
||||||
|
We now only check if nats is available when the gateway actually uses it. Furthermore, we added a backoff for checking the readys endpoint.
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/10502
|
||||||
@@ -27,11 +27,15 @@ func RegisterService(ctx context.Context, logger log.Logger, service *mRegistry.
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// check if the service is ready
|
// check if the service is ready
|
||||||
|
delay := 500 * time.Millisecond
|
||||||
for {
|
for {
|
||||||
resp, err := http.DefaultClient.Get("http://" + debugAddr + "/readyz")
|
resp, err := http.DefaultClient.Get("http://" + debugAddr + "/readyz")
|
||||||
if err == nil && resp.StatusCode == http.StatusOK {
|
if err == nil && resp.StatusCode == http.StatusOK {
|
||||||
|
resp.Body.Close()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
time.Sleep(delay)
|
||||||
|
delay *= 2
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ func Server(opts ...Option) (*http.Server, error) {
|
|||||||
readyHandlerConfiguration := handlers.NewCheckHandlerConfiguration().
|
readyHandlerConfiguration := handlers.NewCheckHandlerConfiguration().
|
||||||
WithLogger(options.Logger).
|
WithLogger(options.Logger).
|
||||||
WithCheck("nats reachability", func(ctx context.Context) error {
|
WithCheck("nats reachability", func(ctx context.Context) error {
|
||||||
if len(options.Config.Cache.ProviderCacheNodes) > 0 {
|
if options.Config.Cache.ProviderCacheStore == "nats-js-kv" && len(options.Config.Cache.ProviderCacheNodes) > 0 {
|
||||||
return checks.NewNatsCheck(options.Config.Cache.ProviderCacheNodes[0])(ctx)
|
return checks.NewNatsCheck(options.Config.Cache.ProviderCacheNodes[0])(ctx)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user