{"id":38633703,"url":"https://github.com/schigh/health","last_synced_at":"2026-01-17T09:01:41.042Z","repository":{"id":224290705,"uuid":"671643743","full_name":"schigh/health","owner":"schigh","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-04T14:52:08.000Z","size":149,"stargazers_count":8,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-17T16:05:56.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/schigh.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-27T19:51:59.000Z","updated_at":"2025-06-17T01:04:10.000Z","dependencies_parsed_at":"2024-03-04T16:33:02.098Z","dependency_job_id":"00d3d522-223b-448e-9c85-a596efa012b1","html_url":"https://github.com/schigh/health","commit_stats":null,"previous_names":["schigh/health"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/schigh/health","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fhealth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fhealth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fhealth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fhealth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schigh","download_url":"https://codeload.github.com/schigh/health/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fhealth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-17T09:01:39.652Z","updated_at":"2026-01-17T09:01:41.003Z","avatar_url":"https://github.com/schigh.png","language":"Go","funding_links":[],"categories":["Distributed Systems"],"sub_categories":["Search and Analytic Databases"],"readme":"# Health\n\nThis library provides a mechanism for a service to check its health and report it \nto any type of listener. The most common use case for this library is a service \nrunning as a kubernetes pod, but it is useful in any running Go service.\n\n## Concepts\n\n### Manager\nThe manager is responsible for managing individual health checks and subsequent \nreporters. It handles setup and teardown of checkers and reporters. It also manages \ncheck frequencies and whether liveness and readiness should be affected\n\n### Checker\nA checker is anything that implements the `Checker` interface. For one-off checks, \nyou can use the `CheckerFunc` type to wrap them (see example below).\n\n### Reporter\nA reporter is anything that reports the status of health checks. The current reporters are:\n\n#### `httpserver`\nThis reporter runs an HTTP server (default port 8181) that reports liveness at `/health/live` \nand readiness at `/health/ready`. Passing checks will always return an HTTP 200 (OK) response, \nwhile failing checks will always return an HTTP 503 (Service Unavailable) response.\n\n#### `stdout`\nThis reporter prints to stdout\n\n#### `test`\nthis reporter can be used for tests\n\n## Basic Example\nThe following is a basic example of how this library can be used\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os/signal\"\n\t\"syscall\"\n\t\"time\"\n\n\t\"github.com/schigh/health\"\n\t\"github.com/schigh/health/manager/std\"\n\thealthpb \"github.com/schigh/health/pkg/v1\"\n\t\"github.com/schigh/health/reporter/stdout\"\n)\n\nfunc main() {\n\tctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)\n\tdefer cancel()\n\n\t// create an instance of a health check manager\n\tmgr := std.Manager{}\n\n\t// add a spurious health check that runs at a 5-second interval\n\t_ = mgr.AddCheck(\n\t\t\"test_check\",\n\t\thealth.CheckerFunc(func(ctx context.Context) *healthpb.Check {\n\t\t\tlog.Print(\"Running health check\")\n\t\t\treturn \u0026healthpb.Check{\n\t\t\t\tName:             \"test_check\",\n\t\t\t\tHealthy:          true,\n\t\t\t\tAffectsLiveness:  true,\n\t\t\t\tAffectsReadiness: true,\n\t\t\t}\n\t\t}),\n\t\thealth.WithCheckFrequency(health.CheckAtInterval, 5*time.Second, 0),\n\t\thealth.WithCheckImpact(true, true),\n\t)\n\n\t// add a reporter\n\t_ = mgr.AddReporter(\"stdout\", \u0026stdout.Reporter{})\n\n\t// run the manager\n\t// This returns a read-only error channel. You can ignore this if you like.\n\terrChan := mgr.Run(ctx)\n\n\t// this toy example won't pipe any errors, but the handling \n\t// is here to demonstrate how that should be done\n\tfor {\n\t\tselect {\n\t\tcase err := \u003c-errChan:\n\t\t\tlog.Printf(\"error: %v\", err)\n\t\tcase \u003c-ctx.Done():\n\t\t\t_ = mgr.Stop(ctx) // remember to stop the manager\n\t\t\treturn\n\t\t}\n\t}\n}\n```\n\n## Planned updates\n- ~currently the http reporter used the chi muxxer. I plan to remove it and just use servemux~\n- The documentation was hastily assembled, it's definitely WIP\n- add more examples\n- add more basic checkers","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschigh%2Fhealth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschigh%2Fhealth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschigh%2Fhealth/lists"}