Added simple healthcheck

This commit is contained in:
Quentin McGaw (desktop)
2020-02-08 21:50:17 +00:00
parent a76aa5276d
commit 321579333d
4 changed files with 39 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
package healthcheck
import (
"fmt"
"strings"
"time"
"github.com/qdm12/golibs/network"
)
func HealthCheck() error {
// DNS, HTTP and HTTPs check on github.com
connectivty := network.NewConnectivity(3 * time.Second)
errs := connectivty.Checks("github.com")
if len(errs) > 0 {
var errsStr []string
for _, err := range errs {
errsStr = append(errsStr, err.Error())
}
return fmt.Errorf("Multiple errors: %s", strings.Join(errsStr, "; "))
}
// TODO check IP address is in the right region
return nil
}