{"id":13563632,"url":"https://github.com/hellofresh/health-go","last_synced_at":"2026-01-09T23:03:14.246Z","repository":{"id":21661557,"uuid":"93058363","full_name":"hellofresh/health-go","owner":"hellofresh","description":"Library to provide basic healthcheck functionality to Go applications.","archived":false,"fork":false,"pushed_at":"2024-04-15T03:14:13.000Z","size":387,"stargazers_count":503,"open_issues_count":9,"forks_count":55,"subscribers_count":222,"default_branch":"master","last_synced_at":"2024-08-01T13:29:37.524Z","etag":null,"topics":["docker","golang-library","kubernetes","microservice","open-source"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellofresh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-01T13:09:26.000Z","updated_at":"2024-07-31T15:31:20.000Z","dependencies_parsed_at":"2024-01-18T09:33:59.696Z","dependency_job_id":"c0eb84a1-71be-42ae-a054-4571b0fcf2ac","html_url":"https://github.com/hellofresh/health-go","commit_stats":{"total_commits":218,"total_committers":35,"mean_commits":6.228571428571429,"dds":0.6559633027522935,"last_synced_commit":"3e9e175e20e0b7f5ae550dbd8bc69c7a488e91df"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellofresh%2Fhealth-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellofresh%2Fhealth-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellofresh%2Fhealth-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellofresh%2Fhealth-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellofresh","download_url":"https://codeload.github.com/hellofresh/health-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223030660,"owners_count":17076471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","golang-library","kubernetes","microservice","open-source"],"created_at":"2024-08-01T13:01:21.559Z","updated_at":"2026-01-09T23:03:14.231Z","avatar_url":"https://github.com/hellofresh.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# health-go\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/hellofresh/health-go)](https://goreportcard.com/report/github.com/hellofresh/health-go)\n[![Go Doc](https://godoc.org/github.com/hellofresh/health-go?status.svg)](https://godoc.org/github.com/hellofresh/health-go)\n\n* Exposes an HTTP handler that retrieves health status of the application\n* Implements some generic checkers for the following services:\n  * RabbitMQ\n  * PostgreSQL\n  * Redis\n  * HTTP\n  * MongoDB\n  * MySQL\n  * gRPC\n  * Memcached\n  * InfluxDB\n  * Nats\n\n## Usage\n\nThe library exports `Handler` and `HandlerFunc` functions which are fully compatible with `net/http`.\n\nAdditionally, library exports `Measure` function that returns summary status for all the registered health checks,\nso it can be used in non-HTTP environments.\n\n### Handler\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/hellofresh/health-go/v5\"\n\thealthMysql \"github.com/hellofresh/health-go/v5/checks/mysql\"\n)\n\nfunc main() {\n\t// add some checks on instance creation\n\th, _ := health.New(health.WithComponent(health.Component{\n\t\tName:    \"myservice\",\n\t\tVersion: \"v1.0\",\n\t}), health.WithChecks(health.Config{\n\t\tName:      \"rabbitmq\",\n\t\tTimeout:   time.Second * 5,\n\t\tSkipOnErr: true,\n\t\tCheck: func(ctx context.Context) error {\n\t\t\t// rabbitmq health check implementation goes here\n\t\t\treturn nil\n\t\t}}, health.Config{\n\t\tName: \"mongodb\",\n\t\tCheck: func(ctx context.Context) error {\n\t\t\t// mongo_db health check implementation goes here\n\t\t\treturn nil\n\t\t},\n\t},\n\t))\n\n\t// and then add some more if needed\n\th.Register(health.Config{\n\t\tName:      \"mysql\",\n\t\tTimeout:   time.Second * 2,\n\t\tSkipOnErr: false,\n\t\tCheck: healthMysql.New(healthMysql.Config{\n\t\t\tDSN: \"test:test@tcp(0.0.0.0:31726)/test?charset=utf8\",\n\t\t}),\n\t})\n\n\thttp.Handle(\"/status\", h.Handler())\n\thttp.ListenAndServe(\":3000\", nil)\n}\n```\n\n### HandlerFunc\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/go-chi/chi\"\n\t\"github.com/hellofresh/health-go/v5\"\n\thealthMysql \"github.com/hellofresh/health-go/v5/checks/mysql\"\n)\n\nfunc main() {\n\t// add some checks on instance creation\n\th, _ := health.New(health.WithComponent(health.Component{\n\t\tName:    \"myservice\",\n\t\tVersion: \"v1.0\",\n\t}), health.WithChecks(health.Config{\n\t\tName:      \"rabbitmq\",\n\t\tTimeout:   time.Second * 5,\n\t\tSkipOnErr: true,\n\t\tCheck: func(ctx context.Context) error {\n\t\t\t// rabbitmq health check implementation goes here\n\t\t\treturn nil\n\t\t}}, health.Config{\n\t\tName: \"mongodb\",\n\t\tCheck: func(ctx context.Context) error {\n\t\t\t// mongo_db health check implementation goes here\n\t\t\treturn nil\n\t\t},\n\t},\n\t))\n\n\t// and then add some more if needed\n\th.Register(health.Config{\n\t\tName:      \"mysql\",\n\t\tTimeout:   time.Second * 2,\n\t\tSkipOnErr: false,\n\t\tCheck: healthMysql.New(healthMysql.Config{\n\t\t\tDSN: \"test:test@tcp(0.0.0.0:31726)/test?charset=utf8\",\n\t\t}),\n\t})\n\n\tr := chi.NewRouter()\n\tr.Get(\"/status\", h.HandlerFunc)\n\thttp.ListenAndServe(\":3000\", nil)\n}\n```\n\nFor more examples please check [here](https://github.com/hellofresh/health-go/blob/master/_examples/server.go)\n## API Documentation\n\n### `GET /status`\n\nGet the health of the application.\n- Method: `GET`\n- Endpoint: `/status`\n- Request:\n```\ncurl localhost:3000/status\n```\n- Response:\n\nHTTP/1.1 200 OK\n```json\n{\n  \"status\": \"OK\",\n  \"timestamp\": \"2017-01-01T00:00:00.413567856+033:00\",\n  \"system\": {\n    \"version\": \"go1.8\",\n    \"goroutines_count\": 4,\n    \"total_alloc_bytes\": 21321,\n    \"heap_objects_count\": 21323,\n    \"alloc_bytes\": 234523\n  },\n  \"component\": {\n    \"name\": \"myservice\",\n    \"version\": \"v1.0\"\n  }\n}\n```\n\nHTTP/1.1 200 OK\n```json\n{\n  \"status\": \"Partially Available\",\n  \"timestamp\": \"2017-01-01T00:00:00.413567856+033:00\",\n  \"failures\": {\n    \"rabbitmq\": \"Failed during rabbitmq health check\"\n  },\n  \"system\": {\n    \"version\": \"go1.8\",\n    \"goroutines_count\": 4,\n    \"total_alloc_bytes\": 21321,\n    \"heap_objects_count\": 21323,\n    \"alloc_bytes\": 234523\n  },\n  \"component\": {\n    \"name\": \"myservice\",\n    \"version\": \"v1.0\"\n  }\n}\n```\n\nHTTP/1.1 503 Service Unavailable\n```json\n{\n  \"status\": \"Unavailable\",\n  \"timestamp\": \"2017-01-01T00:00:00.413567856+033:00\",\n  \"failures\": {\n    \"mongodb\": \"Failed during mongodb health check\"\n  },\n  \"system\": {\n    \"version\": \"go1.8\",\n    \"goroutines_count\": 4,\n    \"total_alloc_bytes\": 21321,\n    \"heap_objects_count\": 21323,\n    \"alloc_bytes\": 234523\n  },\n  \"component\": {\n    \"name\": \"myservice\",\n    \"version\": \"v1.0\"\n  }\n}\n```\n\n## Contributing\n- Fork it\n- Create your feature branch (`git checkout -b my-new-feature`)\n- Commit your changes (`git commit -am 'Add some feature'`)\n- Push to the branch (`git push origin my-new-feature`)\n- Create new Pull Request\n\n---\n\u003e GitHub [@hellofresh](https://github.com/hellofresh) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Medium [@engineering.hellofresh](https://engineering.hellofresh.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellofresh%2Fhealth-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellofresh%2Fhealth-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellofresh%2Fhealth-go/lists"}