{"id":23391487,"url":"https://github.com/armiiller/deferred_request","last_synced_at":"2026-05-01T19:34:47.260Z","repository":{"id":38981912,"uuid":"455621477","full_name":"armiiller/deferred_request","owner":"armiiller","description":"Defer Rails HTTP Request until you can actually process them (think status callbacks like Stripe, Twilio, ect). Helps prevent 3rd party services from DDoSing your app","archived":false,"fork":false,"pushed_at":"2023-05-01T23:57:33.000Z","size":74,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-21T07:59:18.896Z","etag":null,"topics":["rails","ruby"],"latest_commit_sha":null,"homepage":"","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/armiiller.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"MIT-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},"funding":{"github":["armiiller"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2022-02-04T16:38:55.000Z","updated_at":"2025-06-28T12:05:22.000Z","dependencies_parsed_at":"2025-04-08T14:59:47.171Z","dependency_job_id":null,"html_url":"https://github.com/armiiller/deferred_request","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/armiiller/deferred_request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armiiller%2Fdeferred_request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armiiller%2Fdeferred_request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armiiller%2Fdeferred_request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armiiller%2Fdeferred_request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/armiiller","download_url":"https://codeload.github.com/armiiller/deferred_request/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/armiiller%2Fdeferred_request/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32510808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["rails","ruby"],"created_at":"2024-12-22T04:17:50.681Z","updated_at":"2026-05-01T19:34:47.240Z","avatar_url":"https://github.com/armiiller.png","language":"Ruby","funding_links":["https://github.com/sponsors/armiiller"],"categories":[],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/deferred_request.svg)](https://badge.fury.io/rb/deferred_request)\n\n# Deferred Request\nA simple plugin to defer an http request until you can actually process it. This is good in situtations where work performed is not needed immidiately (think status callbacks from services like Twilio or Stripe). This pattern can help prevent you from getting DDoS'd by services you might interact with.\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"deferred_request\"\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nOr install it yourself as:\n```bash\n$ gem install deferred_request\n```\n\n### Migrations\nCopy the Deferred Request migrations to your app:\n\n```bash\nbin/rails deferred_request:install:migrations\n```\n\nThen, run the migrations:\n\n```bash\nbin/rails db:migrate\n```\n\n## Usage\n\n### Controllers\nIn your controllers you can use the library like so. **Make sure you add a method with a `_deferred` suffix so that it can be processed later**\n\n```ruby\n# app/controllers/twilio.rb\n\n# ... (snipped for brevity)\ndef status_callback\n  # We can go ahead and give a :ok response (fast and snappy)\n  head :ok\n\n  # Then queue the request to run later\n  deferred_request = DeferredRequest::DeferredRequest.perform_later_from_request!(request)\nend\n\n# Your deferred request method will be called later (via a job)\n# deferred_request will be of type DeferredRequest::DeferredRequest\ndef status_callback_deferred(deferred_request)\n  # do some actual processing\n  if deferred_request.params[\"SmsStatus\"] == \"delivered\"\n    # mark message as delivered\n  end\n\n  # return a status and it will be saved to the database\n  true\nend\n# ...\n```\n\n### Class Methods\n- `DeferredRequest::DeferredRequest.from_request(request)` - returns a DeferredRequest::DeferredRequest object (unsaved). Returns the DeferredRequest::DeferredRequest instance.\n- `DeferredRequest::DeferredRequest.perform_later_from_request!(request)` - creates a deferred request (saved) and enqueues job to process the request. Returns the DeferredRequest::DeferredRequest instance.\n\n### Instance Methods\n- `deferred_request.perform_later` - Enqueues a job to `perform!` the deferred request later. Returns the job id.\n- `deferred_request.perform!` - Calls the `#{controller}_deferred(deferred_request)` method to be processed. Returns the deferred_request instance or raises an exception.\n\n## Configuration\n\n- `DeferredRequest.model_parent_class` - Set the parent class\n- `DeferredRequest.deferred_request_instance_class` - Set the instance class that is created (in-case you sub-class)\n- `DeferredRequest.job_queue` - Set the job queue for the deferred request job\n\n```ruby\n# config/initializers/deferred_request.rb\nDeferredRequest.model_parent_class = \"MyParentClass\"\nDeferredRequest.job_queue = \"low\"\n```\n\n\n## 🙏 Contributing\n\nIf you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.\n\nIf you'd like to open a PR please make sure the following things pass:\n\n```ruby\nbin/rails db:test:prepare\nbin/rails test\nbundle exec standardrb\n```\n\n## 📝 License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmiiller%2Fdeferred_request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farmiiller%2Fdeferred_request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farmiiller%2Fdeferred_request/lists"}