-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3508 from owncloud/health-reference
Add reference implementation for health & readiness endpoint in IDP
- Loading branch information
Showing
2 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |