ipt-loadbalancer/pkg/healthcheck/registry.go
Knut Ahlers 171b80e751
Add SMTP healthcheck
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-11-14 14:59:03 +01:00

39 lines
980 B
Go

// Package healthcheck contains the interface checks have to implement
// and a registry to get them by name
package healthcheck
import (
"git.luzifer.io/luzifer/ipt-loadbalancer/pkg/config"
"git.luzifer.io/luzifer/ipt-loadbalancer/pkg/healthcheck/common"
"git.luzifer.io/luzifer/ipt-loadbalancer/pkg/healthcheck/http"
"git.luzifer.io/luzifer/ipt-loadbalancer/pkg/healthcheck/smtp"
"git.luzifer.io/luzifer/ipt-loadbalancer/pkg/healthcheck/tcp"
"github.com/Luzifer/go_helpers/v2/fieldcollection"
)
type (
// Checker defines the interface a healthcheck must support
Checker interface {
Check(settings *fieldcollection.FieldCollection, target config.Target) error
Help() []common.SettingHelp
}
)
// ByName returns the Checker for the given name or nil if that name
// is not registered
func ByName(name string) Checker {
switch name {
case "http":
return http.New()
case "smtp":
return smtp.New()
case "tcp":
return tcp.New()
default:
return nil
}
}