Last active
April 11, 2017 03:40
-
-
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
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
// 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