Bugfix: Fix health and ready endpoint checker configurations

This commit is contained in:
Florian Schade
2024-10-17 14:34:04 +02:00
parent 08b33627b2
commit 0437722353
36 changed files with 121 additions and 357 deletions
+16 -23
View File
@@ -17,27 +17,21 @@ import (
func Server(opts ...Option) (*http.Server, error) {
options := newOptions(opts...)
healthHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger),
)
readyHandler := handlers.NewCheckHandler(
handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithCheck("nats reachability", checks.NewNatsCheck(options.Config.Events.Cluster)).
WithCheck("antivirus reachability", func(ctx context.Context) error {
cfg := options.Config
switch cfg.Scanner.Type {
default:
return errors.New("no antivirus configured")
case "clamav":
return clamd.NewClamd(cfg.Scanner.ClamAV.Socket).Ping()
case "icap":
return checks.NewTCPCheck(cfg.Scanner.ICAP.URL)(ctx)
}
}),
)
readyHandlerConfiguration := handlers.NewCheckHandlerConfiguration().
WithLogger(options.Logger).
WithLogger(options.Logger).
WithCheck("nats reachability", checks.NewNatsCheck(options.Config.Events.Cluster)).
WithCheck("antivirus reachability", func(ctx context.Context) error {
cfg := options.Config
switch cfg.Scanner.Type {
default:
return errors.New("no antivirus configured")
case "clamav":
return clamd.NewClamd(cfg.Scanner.ClamAV.Socket).Ping()
case "icap":
return checks.NewTCPCheck(cfg.Scanner.ICAP.URL)(ctx)
}
})
return debug.NewService(
debug.Logger(options.Logger),
@@ -47,7 +41,6 @@ func Server(opts ...Option) (*http.Server, error) {
debug.Token(options.Config.Debug.Token),
debug.Pprof(options.Config.Debug.Pprof),
debug.Zpages(options.Config.Debug.Zpages),
debug.Health(healthHandler),
debug.Ready(readyHandler),
debug.Ready(handlers.NewCheckHandler(readyHandlerConfiguration)),
), nil
}