{"id":39013522,"url":"https://github.com/heartwilltell/hc","last_synced_at":"2026-01-17T17:23:16.887Z","repository":{"id":53767364,"uuid":"267046597","full_name":"heartwilltell/hc","owner":"heartwilltell","description":"👩‍⚕️👨‍⚕️ Mission-critical concurrent health checks synchronization","archived":false,"fork":false,"pushed_at":"2025-05-02T10:36:33.000Z","size":39,"stargazers_count":31,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-02T11:42:12.609Z","etag":null,"topics":["go","golang","health-check","health-checks","healthcheck","healthchecks"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/heartwilltell/hc?tab=doc","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/heartwilltell.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,"zenodo":null}},"created_at":"2020-05-26T13:13:02.000Z","updated_at":"2025-05-02T10:35:46.000Z","dependencies_parsed_at":"2025-05-02T11:30:00.333Z","dependency_job_id":"086532a4-9baf-4d40-a199-0b355eb708f7","html_url":"https://github.com/heartwilltell/hc","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/heartwilltell/hc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Fhc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Fhc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Fhc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Fhc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heartwilltell","download_url":"https://codeload.github.com/heartwilltell/hc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heartwilltell%2Fhc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28512748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","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":["go","golang","health-check","health-checks","healthcheck","healthchecks"],"created_at":"2026-01-17T17:23:16.585Z","updated_at":"2026-01-17T17:23:16.847Z","avatar_url":"https://github.com/heartwilltell.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 👩‍⚕️👨‍⚕️ hc\n\n`hc` is a tiny library for synchronization of mission critical concurrent health checks\n\nThe `HealthChecker` interface is a heart of this small library.\n\n```go\n// HealthChecker represents logic of making the health check.\ntype HealthChecker interface {\n\t// Health takes the context and performs the health check.\n\t// Returns nil in case of success or an error in case\n\t// of a failure.\n\tHealth(ctx context.Context) error\n}\n```\n\n## Usage\n\nLet's say that we have a web application with some upstream services (database, remote storage etc.),\nWork of these services is critical for our application. So we need to check if they are reachable and healthy,\nto provide the overall service health check information to orchestrator or load balancer.\n\nWith `hc` it is simple. You just need to implement the `HealthChecker` interface for you're downstream.\n\n```go\n// PgUpstreamService holds logic of interaction\n// with Postgres database.\ntype PgUpstreamService struct {\n    db *pgxpool.Pool\n}\n\nfunc (s *PgUpstreamService) Health(ctx context.Context) error {\n    conn, err := s.db.Acquire(ctx)\n    if err != nil {\n        return fmt.Errorf(\"unable to aquire connection from pool: %w\", err)\n    }\n\n    defer conn.Release()\n\n    q := `SELECT count(*) FROM information_schema.tables WHERE table_type='public';`\n\n    var count int\n\n    if err := conn.QueryRow(ctx, q).Scan(\u0026count); err != nil {\n        return fmt.Errorf(\"query failed: %w\", err)\n    }\n\n    return nil\n}\n```\n\nNow in your http server health check endpoint you just need to gather information about all upstream health checks.\n\n```go\nchecker := hc.NewMultiChecker(pgUpstream, storageUpstream)\n\nmux := http.NewServeMux()\n\nmux.HandleFunc(\"/health\", func(w http.ResponseWriter, r *http.Request) {\n    if err := checker.Health(r.Context()); err != nil {\n        w.WriteHeader(http.StatusServiceUnavailable)\n        return\n    }\n\n    w.WriteHeader(http.StatusOK)\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheartwilltell%2Fhc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheartwilltell%2Fhc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheartwilltell%2Fhc/lists"}