{"id":44057243,"url":"https://github.com/oliwer/thc","last_synced_at":"2026-02-08T00:37:24.885Z","repository":{"id":68758601,"uuid":"126475622","full_name":"oliwer/thc","owner":"oliwer","description":"Go HTTP client with metrics and circuit breaker","archived":false,"fork":false,"pushed_at":"2018-06-06T15:22:45.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-20T13:28:16.098Z","etag":null,"topics":["circuit-breaker","go","golang","http","metrics","monitoring"],"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/oliwer.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":"2018-03-23T11:23:20.000Z","updated_at":"2019-08-09T05:29:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"c0c0fab2-0b36-41a7-92bb-9954c2be348c","html_url":"https://github.com/oliwer/thc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/oliwer/thc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliwer%2Fthc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliwer%2Fthc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliwer%2Fthc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliwer%2Fthc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oliwer","download_url":"https://codeload.github.com/oliwer/thc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliwer%2Fthc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29214398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T00:10:47.190Z","status":"ssl_error","status_checked_at":"2026-02-08T00:10:43.589Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["circuit-breaker","go","golang","http","metrics","monitoring"],"created_at":"2026-02-08T00:37:24.292Z","updated_at":"2026-02-08T00:37:24.880Z","avatar_url":"https://github.com/oliwer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"THC - Timed HTTP Client for Go\n==============================\n\n[![GoDoc](https://godoc.org/github.com/oliwer/thc?status.svg)](https://godoc.org/github.com/oliwer/thc)\n[![Build Status](https://travis-ci.org/oliwer/thc.svg)](https://travis-ci.org/oliwer/thc)\n[![Go Report Card](https://goreportcard.com/badge/oliwer/thc)](https://goreportcard.com/report/oliwer/thc)\n\nTHC is a thin wrapper around Go's `http.Client` package which provides the following extra features.\n\n## Metrics\n\nTHC exports metrics of your requests using `expvar`. You can observe average times for DNS lookups,\nTLS handshakes, TCP sessions and more. Look at [the documentation](https://godoc.org/github.com/oliwer/thc)\nfor a list of exported metrics.\n\n## Circuit breaker\n\nAfter a defined number of consecutive failures, THC will switch to an *out of service* state.\nIn this state, the client will stop sending HTTP requests and instead will return the error\n`ErrOutOfService`. It is up to the application to decide what to do in that case. After a\npredefined amount of time, the service will be restores and THC will resume to work normally.\n\n# Example\n\n```go\npackage main\n\nimport (\n    \"net/http\"\n    \"time\"\n\n    \"github.com/oliwer/thc\"\n)\n\nvar client = \u0026thc.THC{\n    Client:      \u0026http.Client{Timeout: 100 * time.Millisecond},\n    Name:        \"example\",\n    MaxErrors:   10,\n    HealingTime: 20 * time.Second,\n}\n\nfunc init() {\n    client.PublishExpvar()\n}\n\nfunc main() {\n    for {\n        resp, err := client.Get(\"https://example.com/thing.json\")\n\n        if err == thc.ErrOutOfService {\n            // The service is down for 20s. (HealingTime)\n        }\n\n        if err != nil {\n            // There was an error but we are still OK because\n            // still under MaxErrors consecutive errors.\n        }\n\n        // Process resp normally...\n    }\n}\n```\n\n# Notes\n\nTHC requires Go v1.8 or above. It is thread-safe and lock-less.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliwer%2Fthc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliwer%2Fthc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliwer%2Fthc/lists"}