enhancement: simplify ready and health check handler usage

This commit is contained in:
Florian Schade
2024-10-16 20:26:00 +02:00
parent 0ea4312668
commit 66ff86bd35
27 changed files with 207 additions and 82 deletions
+5 -4
View File
@@ -4,6 +4,7 @@ import (
"context"
"net/http"
"github.com/owncloud/ocis/v2/ocis-pkg/checks"
"github.com/owncloud/ocis/v2/ocis-pkg/handlers"
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug"
"github.com/owncloud/ocis/v2/ocis-pkg/version"
@@ -16,20 +17,20 @@ func Server(opts ...Option) (*http.Server, error) {
checkHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithCheck("grpc reachability", handlers.NewGRPCCheck(options.Config.GRPC.Addr)),
WithCheck("grpc reachability", checks.NewGRPCCheck(options.Config.GRPC.Addr)),
)
readyHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithCheck("nats reachability", handlers.NewNatsCheck(options.Config.Events.Cluster)).
WithCheck("nats reachability", checks.NewNatsCheck(options.Config.Events.Cluster)).
WithCheck("tika-check", func(ctx context.Context) error {
if options.Config.Extractor.Type == "tika" {
return handlers.NewTCPCheck(options.Config.Extractor.Tika.TikaURL)(ctx)
return checks.NewTCPCheck(options.Config.Extractor.Tika.TikaURL)(ctx)
}
return nil
}).
WithInheritedChecksFrom(checkHandler.Conf),
WithChecks(checkHandler.Checks()),
)
return debug.NewService(