Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.