Skip to content

Instantly share code, notes, and snippets.

@HootAdam
Last active April 11, 2017 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HootAdam/d1b2eb462c7ab0d96750f32e9f085be0 to your computer and use it in GitHub Desktop.
Save HootAdam/d1b2eb462c7ab0d96750f32e9f085be0 to your computer and use it in GitHub Desktop.
Define a simple sql db status check using the Go Health Checks Framework
// Create a db object by opening the connection
db, err := sql.Open("mysql", "user:password@tcp(127.0.0.1:3306)/a-db")
if err != nil {
log.Fatal(err)
}
// Define a StatusEndpoint at '/status/db' for a database dependency
dbs := healthchecks.StatusEndpoint{
Name: "The DB",
Slug: "db",
Type: "internal",
IsTraversable: false,
StatusCheck: sqlsc.SQLDBStatusChecker{
DB: db
},
TraverseCheck: nil,
}
// Add all your StatusEndpoints to a slice for your service.
// This will be used to initialize the framework in the next step.
statusEndpoints := []healthchecks.StatusEndpoint{ dbs }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment