Provides a JSON object exposing status information, ideal as part of a REST API for internal monitoring.
Import with something akin to:
import servicestatus "github.com/TheBookPeople/golang-service-status"
// Initialize
status := servicestatus.NewServiceStatus("app name", "0.0.1")
// Add service checks
status.AddCheck("Redis Ping", func() bool {
// Perform the check here, return true if passed
return true
})
// Get a JSON string containing service info:
status.Status()
As below. Checks are always part of the 'checks' array. If they have failed, they are included in 'errors' as well.
'Status' is either "online" or "offline".
{
"name": "windows",
"version": "3.11",
"hostname": "clippy",
"checks": [{
"name": "redis",
"description": "Can connect to Redis"
"successful": true
}],
"errors": [],
"timestamp": "2015-05-07 14:35:17",
"uptime": "14d:23:11:21",
"diskusage": "64%",
"status": "online"
}
- Fork it ( https://github.com/[my-github-username]/service-status/fork )
- git flow init -d (assuming you have git flow)
- Create your feature branch (
git flow feature start my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create a new Pull Request
Copyright (c) 2015 The Book People
See LICENSE (GPLv3)