enhancement: simplify ready and health check handler usage
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user