{"id":30883318,"url":"https://github.com/globocom/reliable-request","last_synced_at":"2025-09-08T09:44:35.387Z","repository":{"id":66161264,"uuid":"196595460","full_name":"globocom/reliable-request","owner":"globocom","description":"A golang opinionated library to provide reliable request using hystrix-go, go-cache, and go-resiliency.","archived":false,"fork":false,"pushed_at":"2020-08-28T11:56:17.000Z","size":41,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-18T11:42:41.128Z","etag":null,"topics":["caching","circuit-breaker","golang","http","http-client","reliability","requests","retry-library"],"latest_commit_sha":null,"homepage":"https://github.com/globocom/reliable-request","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/globocom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2019-07-12T14:41:51.000Z","updated_at":"2025-03-02T13:18:48.000Z","dependencies_parsed_at":"2023-09-24T07:16:45.996Z","dependency_job_id":null,"html_url":"https://github.com/globocom/reliable-request","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":0.5172413793103448,"last_synced_commit":"290b90e26d431c6aad2e6e160cf24ed3789bd090"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/globocom/reliable-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Freliable-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Freliable-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Freliable-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Freliable-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/globocom","download_url":"https://codeload.github.com/globocom/reliable-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globocom%2Freliable-request/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274166945,"owners_count":25233959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"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":["caching","circuit-breaker","golang","http","http-client","reliability","requests","retry-library"],"created_at":"2025-09-08T09:44:29.648Z","updated_at":"2025-09-08T09:44:35.358Z","avatar_url":"https://github.com/globocom.png","language":"Go","readme":"# Reliablereq\n[![Build Status](https://travis-ci.org/globocom/reliable-request.svg?branch=master)](https://travis-ci.org/globocom/reliable-request) [![Go Report Card](https://goreportcard.com/badge/github.com/globocom/reliable-request)](https://goreportcard.com/report/github.com/globocom/reliable-request)\n\nA golang opinionated library to provide reliable request using [hystrix-go](https://github.com/afex/hystrix-go), [go-cache](https://github.com/patrickmn/go-cache), and [go-resiliency](https://github.com/eapache/go-resiliency).\n\nWhen you do a `Get`, it provides:\n* an HTTP client configured with timeouts and [keepalive](https://en.wikipedia.org/wiki/HTTP_persistent_connection),\n* a [circuit breaker](https://martinfowler.com/bliki/CircuitBreaker.html) and\n* a proper [caching system](https://en.wikipedia.org/wiki/Cache_(computing)).\n\n# Usage\n\n```golang\nreq := reliablereq.NewReliableRequest()\nreq.TTLCache = 1 * time.Second\nreq.EnableStaleCache = false\nbody, err := req.Get(\"http://example.com/list\")\n\n// passing authentication/authorization bearer token\nreq := reliablereq.NewReliableRequest()\nreq.Headers = map[string]string{\"Authorization\": \"Bearer foobar\"}\nbody, err := req.Get(\"http://example.com/list\")\n\n// creating a different hystrix command\nreq := reliablereq.NewReliableRequest()\nreq.UpdateHystrixConfig(\"api2command\", hystrix.CommandConfig{\n\t\tTimeout:                800 + 100,\n\t\tMaxConcurrentRequests:  100,\n\t\tErrorPercentThreshold:  50,\n\t\tRequestVolumeThreshold: 20,\n\t\tSleepWindow:            5000,\n\t})\n body, err := req.Get(\"http://example.com/list\")\n```\n\n## WARNING\nMake sure you use different Hystrix commands for other endpoint APIs or separated Circuit Breaker contexts, otherwise, an endpoint may open the circuit breaker and all other requests will fail.\n\n\n# Opinionated defaults\n\n```golang\n// reliable request defaults\nrr := ReliableRequest{\n  EnableCache:        true,\n  TTLCache:           1 * time.Minute,\n  EnableStaleCache:   true,\n  TTLStaleCache:      24 * time.Hour,\n}\n// hystrix\nvar defaultHystrixConfiguration = hystrix.CommandConfig{\n  Timeout:                800 + 100, // the defaultTimeout http client + a small gap\n  MaxConcurrentRequests:  100,\n  ErrorPercentThreshold:  50,\n  RequestVolumeThreshold: 3,\n  SleepWindow:            5000,\n}\n// http client\nclient := \u0026http.Client{\n  Transport: \u0026http.Transport{\n    DialContext: (\u0026net.Dialer{\n      Timeout:   800 * time.Millisecond,\n      KeepAlive: 30 * time.Second,\n    }).DialContext,\n    MaxIdleConns:        100,\n    MaxIdleConnsPerHost: 100,\n    TLSHandshakeTimeout: 800 * time.Millisecond,\n  },\n  Timeout: 800 * time.Millisecond,\n}\n```\n\n# Future\n\n* provide a proxy to setup hystrix\n* add retry logic (by go-resiliency)\n* add more examples, like token header requests and more\n* discuss the adopted defaults\n* discuss whether async hystrix is better (Go instead of Do)\n* understand and test the simultaneous client req hystrix config to see its implications\n* add go api documentation\n* add hooks (callbacks) to provides means for metrics gathering\n* add more HTTP verbs?\n* add load stress\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobocom%2Freliable-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglobocom%2Freliable-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobocom%2Freliable-request/lists"}