{"id":37109003,"url":"https://github.com/alxibra/rtry","last_synced_at":"2026-01-14T13:00:39.377Z","repository":{"id":308156672,"uuid":"1031729028","full_name":"alxibra/rtry","owner":"alxibra","description":"RabbitMQ retry queue handler with exponential backoff, jitter, and max-attempt control. Built with Go.","archived":false,"fork":false,"pushed_at":"2025-08-15T08:11:09.000Z","size":217,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-23T14:59:24.631Z","etag":null,"topics":["exponential-backoff","golang","rabbitmq","retry-strategies"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alxibra.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,"zenodo":null}},"created_at":"2025-08-04T08:42:02.000Z","updated_at":"2025-08-15T08:10:07.000Z","dependencies_parsed_at":"2025-08-04T15:46:42.703Z","dependency_job_id":"85cc11ad-cc38-4a52-87fa-f5dc47145540","html_url":"https://github.com/alxibra/rtry","commit_stats":null,"previous_names":["alxibra/rtry"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/alxibra/rtry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alxibra%2Frtry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alxibra%2Frtry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alxibra%2Frtry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alxibra%2Frtry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alxibra","download_url":"https://codeload.github.com/alxibra/rtry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alxibra%2Frtry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420815,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"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":["exponential-backoff","golang","rabbitmq","retry-strategies"],"created_at":"2026-01-14T13:00:23.740Z","updated_at":"2026-01-14T13:00:39.320Z","avatar_url":"https://github.com/alxibra.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Go Version](https://img.shields.io/badge/go-1.18%2B-blue)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](/LICENSE)\n\n# rtry\n\n**rtry** is a lightweight Go library for handling RabbitMQ retry logic using a dedicated retry queue, exponential backoff with jitter, and configurable max-attempt limits. It supports clean separation of retry queue declarations and re-publishing logic when processing fails.\n\n---\n\n##  Features\n\n-  **Exponential backoff with jitter** (customizable)\n-  **Retry metadata** via headers (`x-retry-count`)\n-  **Max retry attempts** with graceful drop logging\n-  **Inject custom backoff strategy**\n-  **Clean RabbitMQ queue setup** (main + retry + bindings)\n\n---\n\n##  Installation\n\n```bash\ngo get github.com/alxibra/rtry@latest\n```\n\n---\n\n## Quick Start\n\n### Minimal Example\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/alxibra/rtry\"\n\tamqp \"github.com/rabbitmq/amqp091-go\"\n)\n\nfunc main() {\n\tconn, chn := initialize()\n\tdefer conn.Close()\n\tdefer chn.Close()\n\n\trty, err := rtry.Init(\n\t\t\"main_exchange\",\n\t\t\"main_queue\",\n\t\t\"retry_queue\",\n\t\t\"main_key\",\n\t\t\"retry_key\",\n\t\tnil,\n\t\tchn,\n\t)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tmsgs, _ := rty.Consume(chn)\n\n\tlog.Println(\"Ready to consume messages.\")\n\tfor msg := range msgs {\n\t\tlog.Printf(\"Received message: %s\", msg.Body)\n\t\trty.Retry(msg, nil, chn)\n\t\tmsg.Ack(false)\n\t}\n}\n\nfunc initialize() (*amqp.Connection, *amqp.Channel) {\n\tconn, err := amqp.Dial(\"amqp://guest:guest@localhost:5672/\")\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to connect to RabbitMQ: %v\", err)\n\t}\n\tch, err := conn.Channel()\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to open a channel: %v\", err)\n\t}\n\treturn conn, ch\n}\n```\n\n### With Custom Options\n\n```go\nrty, err := rtry.Init(\n\t\"main_exchange\",\n\t\"main_queue\",\n\t\"retry_queue\",\n\t\"main_key\",\n\t\"retry_key\",\n\trtry.Option{\n\t\t\"max-attempts\": 3,\n\t\t\"backoff\": func(retryCount int) int {\n\t\t\treturn int(math.Pow(float64(retryCount), 4) + 5) // custom exponential backoff function\n\t\t},\n\t},\n\tchn,\n)\n\nmsgs, _ := rty.Consume(chn)\n\nfor msg := range msgs {\n\trty.Retry(\n\t\tmsg,\n\t\trtry.Option{\n\t\t\t\"delay_in_second\": 5, // if need fixed delayed \n\t\t},\n\t\tchn,\n\t)\n\tmsg.Ack(false)\n}\n```\n\n**Retry Options**\n\n\n| Option Key        | Type             | Description                                      |\n|-------------------|------------------|--------------------------------------------------|\n| `max-attempts`    | `int`            | Maximum retry attempts before dropping           |\n| `backoff`         | `func(int) int`  | Custom backoff strategy per retry count          |\n| `delay_in_second` | `int`            | Fixed delay override (bypasses backoff function) |\n\n##  Requirements\n\n- Go **1.18+**\n- The following dependencies:\n\n```go\nrequire (\n    github.com/fatih/color v1.18.0\n    github.com/rabbitmq/amqp091-go v1.10.0\n    golang.org/x/exp v0.0.0-20250718183923-645b1fa84792\n)\n```\n\n##  Retry Flow Diagram\n\n![Retry Flow](docs/retry-flow.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falxibra%2Frtry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falxibra%2Frtry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falxibra%2Frtry/lists"}