{"id":26437678,"url":"https://github.com/rringler/resque-serializer","last_synced_at":"2025-03-18T08:32:41.515Z","repository":{"id":56891992,"uuid":"86935769","full_name":"rringler/resque-serializer","owner":"rringler","description":"A Resque plugin for ensuring that unique jobs are executed serially","archived":false,"fork":false,"pushed_at":"2019-05-16T22:36:29.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-04-23T22:39:24.113Z","etag":null,"topics":["resque","resque-plugin","ruby"],"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/rringler.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-01T19:01:52.000Z","updated_at":"2023-07-30T00:12:23.000Z","dependencies_parsed_at":"2022-08-20T16:00:53.915Z","dependency_job_id":null,"html_url":"https://github.com/rringler/resque-serializer","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/rringler%2Fresque-serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rringler%2Fresque-serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rringler%2Fresque-serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rringler%2Fresque-serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rringler","download_url":"https://codeload.github.com/rringler/resque-serializer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244184154,"owners_count":20412158,"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":["resque","resque-plugin","ruby"],"created_at":"2025-03-18T08:31:47.868Z","updated_at":"2025-03-18T08:32:41.506Z","avatar_url":"https://github.com/rringler.png","language":"Ruby","readme":"# Resque::Serializer\n\n[![Build Status](https://travis-ci.org/rringler/resque-serializer.svg?branch=master)](https://travis-ci.org/rringler/resque-serializer)\n\nA Resque plugin which ensures for a given queue, that only one worker is executing a job at any given time.\n\nIt is slightly more flexible than [Resque::LonelyJob](https://github.com/wallace/resque-lonely_job).\n\nThis gem may be helpful to avoid database lock contention.\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'resque-serializer'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install resque-serializer\n\n\n## Usage\n\n### TLDR\n```\n|  Lock Lifetime | :queue | :job  | :both  | :combined |\n| -------------: | :----: | :---: | :----: | :-------: |\n| before_enqueue |    ✓   |       |  ✓     |     ✓     |\n|        enqueue |    |   |       |  |     |     |     |\n|  after_enqueue |    |   |       |  |     |     |     |\n| before_dequeue |    |   |   ✓   |  |  ✓  |     |     |\n|        dequeue |    |   |   |   |  |  |  |     |     |\n|  after_dequeue |    ✗   |   |   |  ✗  |  |     |     |\n| before_perform |        |   |   |     |  |     |     |\n|        perform |        |   |   |     |  |     |     |\n|  after_perform |        |   ✗   |     ✗  |     ✗     |\n```\n\n### Example #1 -- Serializing the queue\n\n```ruby\nrequire 'resque-serializer'\n\nclass SerializedJob\n  extend Resque::Plugins::Serializer\n\n  @queue = :default\n\n  serialize :queue\n\n  def self.perform\n    # work\n  end\nend\n```\n\nOnly one of job with identical arguments will be allowed to be queued at a time. As soon as the job is dequeued to begin executing, an identical job may be queued (and may begin executing.)\n\n\n### Example #2 -- Serializing the job\n\n```ruby\nrequire 'resque-serializer'\n\nclass SerializedJob\n  extend Resque::Plugins::Serializer\n\n  @queue = :default\n\n  serialize :job\n\n  def self.perform\n    # work\n  end\nend\n```\n\nAny number of these jobs may be queued, but only one job with identical arguments will be executed at a time. As soon as the executing job is completed, another queued job may be dequeued to execute.\n\n\n### Example #3 -- Serializing both the queue \u0026 job (independently)\n\n```ruby\nrequire 'resque-serializer'\n\nclass SerializedJob\n  extend Resque::Plugins::Serializer\n\n  @queue = :default\n\n  serialize :both\n\n  def self.perform\n    # work\n  end\nend\n```\n\nA combination of the first two examples; both the queue and the execution of identical jobs is serialized (independently.) An additional job may be queued if no identical job exists in the queue. Similarly, an additional job may begin executing if no identical job is currently executing.\n\n\n### Example #4 -- Serializing both the queue \u0026 job (combined)\n\n```ruby\nrequire 'resque-serializer'\n\nclass SerializedJob\n  extend Resque::Plugins::Serializer\n\n  @queue = :default\n\n  serialize :combined\n\n  def self.perform\n    # work\n  end\nend\n```\n\nAlso a combination of the first two examples; both the queue and execution of identical jobs is serialized (together.) An additional job may not be queued if an identical job exists in the queue or execution.\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\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\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frringler%2Fresque-serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frringler%2Fresque-serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frringler%2Fresque-serializer/lists"}