{"id":36757591,"url":"https://github.com/zacscoding/gochecker","last_synced_at":"2026-01-12T12:51:23.549Z","repository":{"id":57559907,"uuid":"325504988","full_name":"zacscoding/gochecker","owner":"zacscoding","description":"Simple health checker for Go application :)","archived":false,"fork":false,"pushed_at":"2022-08-12T16:17:54.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T06:32:32.801Z","etag":null,"topics":["go","health","healthcheck"],"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/zacscoding.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}},"created_at":"2020-12-30T09:09:20.000Z","updated_at":"2022-08-12T16:15:59.000Z","dependencies_parsed_at":"2022-08-28T09:32:35.746Z","dependency_job_id":null,"html_url":"https://github.com/zacscoding/gochecker","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zacscoding/gochecker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacscoding%2Fgochecker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacscoding%2Fgochecker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacscoding%2Fgochecker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacscoding%2Fgochecker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zacscoding","download_url":"https://codeload.github.com/zacscoding/gochecker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacscoding%2Fgochecker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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","health","healthcheck"],"created_at":"2026-01-12T12:51:22.820Z","updated_at":"2026-01-12T12:51:23.538Z","avatar_url":"https://github.com/zacscoding.png","language":"Go","readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/zacscoding/gochecker.svg)](https://pkg.go.dev/github.com/zacscoding/gochecker) ![workflow](https://github.com/zacscoding/gochecker/actions/workflows/go.yaml/badge.svg)  \n\n:heavy_check_mark: Go Health Checker\n===  \n\nSimple health check library for ur Go application :)\n\n# Installation  \n\n```shell\n$ go get github.com/zacscoding/gochecker\n```\n\n# Usage\n\n\u003e Initialize new health checker\n\n```go\npackage main\n\nimport (\n\t\"github.com/zacscoding/gochecker\"\n\t\"time\"\n)\n\nfunc main() {\n\t// This health checker uses cache health result with given TTL\n\tchecker := gochecker.NewHealthChecker(gochecker.WithCacheTTL(time.Minute))\n\n\t// This health checker checks health status with given time interval in a new goroutine\n\tchecker = gochecker.NewHealthChecker(gochecker.WithBackground(time.Minute))\n}\n```  \n\n\u003e Add checkers and observers\n\n```go\npackage main\n\nimport (\n\t\"github.com/zacscoding/gochecker\"\n\t\"github.com/zacscoding/gochecker/database\"\n\t\"time\"\n)\n\nfunc main() {\n\t// Add health check components\n\t// add database component\n\tchecker.AddChecker(\"MyDatabase\", database.NewMySQLIndicator(db))\n\t// add remote service component\n\tchecker.AddChecker(\"RemoteService-1\", gochecker.NewUrlIndicator(\"RemoteService-1\", \"GET\", \"http://anotherservice.com\", nil, time.Second*10))\n\t// add component with function\n\tchecker.AddCheckerFn(\"RemoteService-3\", func(ctx context.Context) gochecker.ComponentStatus {\n\t\tstatus := gochecker.NewComponentStatus()\n\t\t_, err := http.Get(\"https://google.com\")\n\t\tif err != nil {\n\t\t\tstatus.WithDown()\n\t\t\tstatus.WithDetail(\"err\", err.Error())\n\t\t\treturn *status\n\t\t}\n\t\tstatus.WithUp()\n\t\treturn *status\n\t})\n\n\t// Add observers\n\tchecker.AddObserver(\"BatchProcessor\", batchProcessor)\n\tchecker.AddChecker(\"RemoteService-2\", gochecker.NewUrlIndicator(\"RemoteService-2\", \"GET\", \"http://localhost:8890\", nil, time.Second*10))\n}\n```  \n\n\u003e Getting health check result  \n\n```go\nstatus := checker.Health(context.Background())\n```\n\n```json\n{\n  \"status\": \"UP\",\n  \"components\": {\n    \"BatchProcessor\": {\n      \"details\": {\n        \"checkpoint\": \"100\"\n      },\n      \"status\": \"UP\"\n    },\n    \"LocalDatabase\": {\n      \"details\": {\n        \"database\": \"mysql\",\n        \"validationQuery\": \"SELECT 1\",\n        \"version\": \"5.6.1\"\n      },\n      \"status\": \"UP\"\n    },\n    \"RemoteService-1\": {\n      \"details\": {\n        \"status\": 200\n      },\n      \"status\": \"UP\"\n    },\n    \"RemoteService-2\": {\n      \"details\": {\n        \"err\": \"Get \\\"http://localhost:8990\\\": dial tcp [::1]:8990: connect: connection refused\"\n      },\n      \"status\": \"DOWN\"\n    }\n  }\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacscoding%2Fgochecker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzacscoding%2Fgochecker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacscoding%2Fgochecker/lists"}