{"id":13413508,"url":"https://github.com/etherlabsio/healthcheck","last_synced_at":"2025-03-14T19:32:28.763Z","repository":{"id":49433239,"uuid":"100711370","full_name":"etherlabsio/healthcheck","owner":"etherlabsio","description":"An simple, easily extensible and concurrent health-check library for Go services","archived":false,"fork":false,"pushed_at":"2023-12-13T04:01:32.000Z","size":230,"stargazers_count":267,"open_issues_count":4,"forks_count":30,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-07-31T20:52:31.816Z","etag":null,"topics":["api","go","golang","health-check","healthcheck","microservice"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/etherlabsio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-08-18T12:48:40.000Z","updated_at":"2024-07-02T08:17:53.000Z","dependencies_parsed_at":"2024-01-08T15:34:45.233Z","dependency_job_id":null,"html_url":"https://github.com/etherlabsio/healthcheck","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fhealthcheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fhealthcheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fhealthcheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etherlabsio%2Fhealthcheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etherlabsio","download_url":"https://codeload.github.com/etherlabsio/healthcheck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635490,"owners_count":20322949,"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":["api","go","golang","health-check","healthcheck","microservice"],"created_at":"2024-07-30T20:01:41.962Z","updated_at":"2025-03-14T19:32:28.458Z","avatar_url":"https://github.com/etherlabsio.png","language":"Go","funding_links":[],"categories":["Microsoft Office","Miscellaneous","杂项","healthcheck","其他杂项","其他","Uncategorized","\u003cspan id=\"其他-miscellaneous\"\u003e其他 Miscellaneous\u003c/span\u003e"],"sub_categories":["Uncategorized","Strings","未分类的","Advanced Console UIs","暂未分类","交流","暂未分类这些库被放在这里是因为其他类别似乎都不适合。","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"\u003cimg src=\"logo.png\" width=\"500\" align=\"top\"/\u003e\n\n# Healthcheck\n\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)  \n\n[![Build Status](https://travis-ci.com/etherlabsio/healthcheck.svg)](https://travis-ci.com/etherlabsio/healthcheck) [![Go Report Card](https://goreportcard.com/badge/github.com/etherlabsio/healthcheck)](https://goreportcard.com/report/github.com/etherlabsio/healthcheck) [![GoDoc](https://godoc.org/github.com/etherlabsio/healthcheck?status.svg)](https://godoc.org/github.com/etherlabsio/healthcheck) [![codecov](https://codecov.io/gh/etherlabsio/healthcheck/branch/master/graph/badge.svg)](https://codecov.io/gh/etherlabsio/healthcheck) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fetherlabsio%2Fhealthcheck.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fetherlabsio%2Fhealthcheck?ref=badge_shield)\n\nA simple and extensible RESTful Healthcheck API implementation for Go services.\n\nHealth provides an `http.Handlefunc` for use as a healthcheck endpoint used by external services or load balancers. The function is used to determine the health of the application and to remove unhealthy application hosts or containers from rotation.\n\nInstead of blindly returning a `200` HTTP status code, a healthcheck endpoint should test all the mandatory dependencies that are essential for proper functioning of a web service.\n\nImplementing the `Checker` interface and passing it on to healthcheck allows you to test the the dependencies such as a database connection, caches, files and even external services you rely on. You may choose to not fail the healthcheck on failure of certain dependencies such as external services that you are not always dependent on.\n\n## Example\n\n```GO\npackage main\n\nimport (\n    \"context\"\n    \"database/sql\"\n    \"net/http\"\n    \"time\"\n\n    \"github.com/etherlabsio/healthcheck/v2\"\n    \"github.com/etherlabsio/healthcheck/v2/checkers\"\n    _ \"github.com/go-sql-driver/mysql\"\n    \"github.com/gorilla/mux\"\n)\n\nfunc main() {\n    // For brevity, error check is being omitted here.\n    db, _ := sql.Open(\"mysql\", \"user:password@/dbname\")\n    defer db.Close()\n\n    r := mux.NewRouter()\n    r.Handle(\"/healthcheck\", healthcheck.Handler(\n\n        // WithTimeout allows you to set a max overall timeout.\n        healthcheck.WithTimeout(5*time.Second),\n\n        // Checkers fail the status in case of any error.\n        healthcheck.WithChecker(\n            \"heartbeat\", checkers.Heartbeat(\"$PROJECT_PATH/heartbeat\"),\n        ),\n\n        healthcheck.WithChecker(\n            \"database\", healthcheck.CheckerFunc(\n                func(ctx context.Context) error {\n                    return db.PingContext(ctx)\n                },\n            ),\n        ),\n\n        // Observers do not fail the status in case of error.\n        healthcheck.WithObserver(\n            \"diskspace\", checkers.DiskSpace(\"/var/log\", 90),\n        ),\n    ))\n\n    http.ListenAndServe(\":8080\", r)\n}\n```\n\nBased on the example provided above, `curl localhost:8080/healthcheck | jq` should yield on error a response with an HTTP statusCode of `503`.\n\n```JSON\n{\n  \"status\": \"Service Unavailable\",\n  \"errors\": {\n    \"database\": \"dial tcp 127.0.0.1:3306: getsockopt: connection refused\",\n    \"heartbeat\": \"heartbeat not found. application should be out of rotation\"\n  }\n}\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license. See the [LICENSE](LICENSE) file.\n\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fetherlabsio%2Fhealthcheck.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fetherlabsio%2Fhealthcheck?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetherlabsio%2Fhealthcheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetherlabsio%2Fhealthcheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetherlabsio%2Fhealthcheck/lists"}