{"id":22018144,"url":"https://github.com/rvflash/health","last_synced_at":"2026-06-09T16:04:12.177Z","repository":{"id":153917564,"uuid":"631074004","full_name":"rvflash/health","owner":"rvflash","description":"A Go package providing facilities to check liveness or readiness application dependencies.","archived":false,"fork":false,"pushed_at":"2023-04-21T22:30:28.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T23:43:22.003Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rvflash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-04-21T21:31:31.000Z","updated_at":"2023-04-22T08:06:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"776ae4b7-dcaf-481c-b438-5865f0f49337","html_url":"https://github.com/rvflash/health","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rvflash/health","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fhealth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fhealth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fhealth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fhealth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rvflash","download_url":"https://codeload.github.com/rvflash/health/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fhealth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34114456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-30T05:10:09.558Z","updated_at":"2026-06-09T16:04:12.160Z","avatar_url":"https://github.com/rvflash.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Health✓\n\n[![GoDoc](https://godoc.org/github.com/rvflash/health?status.svg)](https://godoc.org/github.com/rvflash/health)\n[![Build Status](https://github.com/rvflash/health/workflows/build/badge.svg)](https://github.com/rvflash/health/actions?workflow=build)\n[![Code Coverage](https://codecov.io/gh/rvflash/health/branch/main/graph/badge.svg)](https://codecov.io/gh/rvflash/health)\n[![Go Report Card](https://goreportcard.com/badge/github.com/rvflash/health?)](https://goreportcard.com/report/github.com/rvflash/health)\n\n\n`health` is a Go package providing facilities to check liveness or readiness application dependencies.\n\n\n## Features\n\n1. Exposes an HTTP handler that retrieves health status of the application with HTTP status code and JSON response.\n   ```json\n   {\n      \"date\":\"2023-04-21T21:54:06.238997+02:00\",\n      \"latency\":\"503.314958ms\",\n      \"status\":\"Request Timeout\",\n      \"errors\":\"mysql: context deadline exceeded: health: readiness probe\"\n   }\n   ```\n2. Available strategies: \n   - `Liveness` to indicate if the probe failed that this instance is unhealthy and should be destroyed or restarted. \u003cbr /\u003e\n   In case of error an HTTP status `ServiceUnavailable` is returned, `GatewayTimeout` in case of deadline exceeded.\n   - `Readiness` to notify if the probe failed that this application should no longer receive any traffic. \u003cbr /\u003e\n   In case of error an HTTP status `FailedDependency` is returned, `RequestTimeout` in case of deadline exceeded.\n3. Each probe has a name, a timeout, a strategy and a function to check.\n4. Function interface used to check any dependency: `func(ctx context.Context) error`.\n5. Provides a ready-to-use function to check file writing.\n\n\n## Example\n\nHere we create a health checker to verify MySQL database connection and NFS write access in directory named `/data`.\n\n```go\n   db, err := sql.Open(\"mysql\", \"user:password@/dbname\")\n   if err != nil {\n      log.Fatal(err)\n   }\n   c := health.New(\n      health.Probe{\n         Strategy: health.Readiness,\n         Timeout:  time.Second,\n         Name:     \"mysql\",\n         Check:    db.PingContext,\n      },\n      health.Probe{\n         Strategy: health.Liveness,\n         Timeout:  time.Second,\n         Name:     \"nfs\",\n         Check:    health.CreateFileCheck(\"/data\", \"check\"),\n      },\n   )\n   http.HandleFunc(\"/health\", health.HandlerFunc(c))\n   log.Fatal(http.ListenAndServe(\":8080\", nil))\n```\n\n\u003e See example directory for another sample.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fhealth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frvflash%2Fhealth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fhealth/lists"}