{"id":15561816,"url":"https://github.com/jcmfernandes/activerecord-retriable","last_synced_at":"2025-04-23T22:41:40.031Z","repository":{"id":56842186,"uuid":"260719527","full_name":"jcmfernandes/activerecord-retriable","owner":"jcmfernandes","description":"Retry your Active Record transactions. :rocket:","archived":false,"fork":false,"pushed_at":"2021-02-11T11:48:40.000Z","size":27,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T18:43:52.914Z","etag":null,"topics":["activerecord","gem","rails","retriable","retry","ruby","transactions"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/jcmfernandes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-02T15:43:38.000Z","updated_at":"2023-03-31T15:51:11.000Z","dependencies_parsed_at":"2022-08-29T06:50:57.677Z","dependency_job_id":null,"html_url":"https://github.com/jcmfernandes/activerecord-retriable","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcmfernandes%2Factiverecord-retriable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcmfernandes%2Factiverecord-retriable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcmfernandes%2Factiverecord-retriable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcmfernandes%2Factiverecord-retriable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcmfernandes","download_url":"https://codeload.github.com/jcmfernandes/activerecord-retriable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528681,"owners_count":21445511,"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","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":["activerecord","gem","rails","retriable","retry","ruby","transactions"],"created_at":"2024-10-02T16:10:06.839Z","updated_at":"2025-04-23T22:41:40.001Z","avatar_url":"https://github.com/jcmfernandes.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveRecord::Retriable\n\n[![Build Status](https://github.com/jcmfernandes/activerecord-retriable/workflows/Test/badge.svg?branch=master\u0026event=push)][gh-actions]\n[![Gem Version](https://img.shields.io/gem/v/activerecord-retriable?style=plastic)][rubygems]\n\n[rubygems]: https://rubygems.org/gems/activerecord-retriable\n[gh-actions]: https://github.com/jcmfernandes/activerecord-retriable/actions?query=workflow%3ATest\n\nRetry your `ActiveRecord` transactions. Inspired by\n[Sequel's](http://sequel.jeremyevans.net/) way of doing it.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activerecord-retriable'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install activerecord-retriable\n\n## Usage\n\nRetry if `ActiveRecord::TransactionRollbackError` is raised:\n\n```ruby\nActiveRecord::Base.transaction(retry_on: ActiveRecord::TransactionRollbackError) do\n  ...\nend\n```\n\nRetry if `ActiveRecord::TransactionRollbackError` or\n`ActiveRecord::LockWaitTimeout` are raised:\n\n```ruby\nActiveRecord::Base.transaction(retry_on: [ActiveRecord::TransactionRollbackError,\n                                          ActiveRecord::LockWaitTimeout]) do\n  ...\nend\n```\n\nBy default we retry once. You can change the default number of retries by\nchanging:\n\n```ruby\nRails.configuration.active_record.default_transaction_retries\n```\n\nOr you can override the default value locally:\n\n```ruby\nActiveRecord::Base.transaction(retry_on: ActiveRecord::TransactionRollbackError\n                               num_retries: 3) do\n  ...\nend\n```\n\nTo retry indefinitely, set `num_retries:` to `nil`. Be careful when doing that!\n\nTo perform an action before retrying, pass an object that responds to `#call` in\n`before_retry:`:\n\n```ruby\nbefore_retry = -\u003e(num_retries, exception) do\n  puts \"retrying transaction for the #{num_retries.ordinalize} time: #{exception}\"\nend\n\nActiveRecord::Base.transaction(retry_on: ActiveRecord::TransactionRollbackError\n                               before_retry: before_retry) do\n  ...\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run\n`rake spec` to run the tests. You can also run `bin/console` for an interactive\nprompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To\nrelease a new version, update the version number in `version.rb`, and then run\n`bundle exec rake release`, which will create a git tag for the version, push\ngit commits and tags, and push the `.gem` file to\n[rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/jcmfernandes/activerecord-retriable. This project is intended\nto be a safe, welcoming space for collaboration, and contributors are expected\nto adhere to the [code of\nconduct](https://github.com/jcmfernandes/activerecord-retriable/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT\nLicense](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the `ActiveRecord::Retriable` project's codebases, issue\ntrackers, chat rooms and mailing lists is expected to follow the [code of\nconduct](https://github.com/jcmfernandes/activerecord-retriable/blob/master/CODE_OF_CONDUCT.md).\n\n## Maintainer\n\nJoão Fernandes \u003cjoao.fernandes@ist.utl.pt\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcmfernandes%2Factiverecord-retriable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcmfernandes%2Factiverecord-retriable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcmfernandes%2Factiverecord-retriable/lists"}