Add reference implementation for health & readiness endpoint in IDP

Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2022-04-11 16:09:09 +02:00
parent 251e5d2b0f
commit 42a4e017c8
2 changed files with 53 additions and 13 deletions
+29
View File
@@ -0,0 +1,29 @@
package shared
import "net"
// Check is a single health-check
type Check func() error
// RunChecklist runs all the given checks
func RunChecklist(checks ...Check) error {
for _, c := range checks {
err := c()
if err != nil {
return err
}
}
return nil
}
// TCPConnect connects to a given tcp endpoint
func TCPConnect(host string) Check {
return func() error {
conn, err := net.Dial("tcp", host)
if err != nil {
return err
}
defer conn.Close()
return nil
}
}