2023-11-13 23:40:07 +00:00
|
|
|
// 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"
|
2023-11-14 12:15:31 +00:00
|
|
|
"git.luzifer.io/luzifer/ipt-loadbalancer/pkg/healthcheck/smtp"
|
2023-11-13 23:40:07 +00:00
|
|
|
"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()
|
|
|
|
|
2023-11-14 12:15:31 +00:00
|
|
|
case "smtp":
|
|
|
|
return smtp.New()
|
|
|
|
|
2023-11-13 23:40:07 +00:00
|
|
|
case "tcp":
|
|
|
|
return tcp.New()
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|