Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example code in server.go updated #58

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions _examples/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@ import (
)

func main() {
h, _ := health.New()
// custom health check example (fail)
health.Register(health.Config{
h.Register(health.Config{
Name: "some-custom-check-fail",
Timeout: time.Second * 5,
SkipOnErr: true,
Check: func(context.Context) error { return errors.New("failed during custom health check") },
})

// custom health check example (success)
health.Register(health.Config{
h.Register(health.Config{
Name: "some-custom-check-success",
Check: func(context.Context) error { return nil },
})

// http health check example
health.Register(health.Config{
h.Register(health.Config{
Name: "http-check",
Timeout: time.Second * 5,
SkipOnErr: true,
Expand All @@ -38,7 +39,7 @@ func main() {
})

// postgres health check example
health.Register(health.Config{
h.Register(health.Config{
Name: "postgres-check",
Timeout: time.Second * 5,
SkipOnErr: true,
Expand All @@ -48,7 +49,7 @@ func main() {
})

// mysql health check example
health.Register(health.Config{
h.Register(health.Config{
Name: "mysql-check",
Timeout: time.Second * 5,
SkipOnErr: true,
Expand All @@ -61,7 +62,7 @@ func main() {
// Use it if your app has access to RabbitMQ management API.
// This endpoint declares a test queue, then publishes and consumes a message. Intended for use by monitoring tools. If everything is working correctly, will return HTTP status 200.
// As the default virtual host is called "/", this will need to be encoded as "%2f".
health.Register(health.Config{
h.Register(health.Config{
Name: "rabbit-aliveness-check",
Timeout: time.Second * 5,
SkipOnErr: true,
Expand All @@ -70,6 +71,6 @@ func main() {
}),
})

http.Handle("/status", health.Handler())
http.Handle("/status", h.Handler())
http.ListenAndServe(":3000", nil)
}