{"id":15562184,"url":"https://github.com/mrkamel/bbque","last_synced_at":"2025-03-29T04:44:11.145Z","repository":{"id":55586254,"uuid":"99316401","full_name":"mrkamel/bbque","owner":"mrkamel","description":"Queue and process ruby job objects in the background","archived":false,"fork":false,"pushed_at":"2023-03-03T20:42:45.000Z","size":45,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T14:37:01.625Z","etag":null,"topics":[],"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/mrkamel.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-04T07:28:34.000Z","updated_at":"2023-03-03T20:42:10.000Z","dependencies_parsed_at":"2025-02-03T14:37:10.285Z","dependency_job_id":"120b6d25-6d2b-417d-9f2a-e7d52d7e6b99","html_url":"https://github.com/mrkamel/bbque","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fbbque","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fbbque/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fbbque/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fbbque/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrkamel","download_url":"https://codeload.github.com/mrkamel/bbque/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140543,"owners_count":20729797,"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":[],"created_at":"2024-10-02T16:12:13.449Z","updated_at":"2025-03-29T04:44:11.124Z","avatar_url":"https://github.com/mrkamel.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BBQue\n\n[![Build Status](https://secure.travis-ci.org/mrkamel/bbque.png?branch=master)](http://travis-ci.org/mrkamel/bbque)\n[![Gem Version](https://badge.fury.io/rb/bbque.svg)](http://badge.fury.io/rb/bbque)\n\nBBQue is an opinionated ruby gem to queue and process background jobs. Other\ngems for this purpose usually don't work with ruby objects, serialize method\narguments only and/or have strong reliability options only in paid/pro versions.\n\nBBQue jobs are simple ruby objects:\n\n```ruby\nMyQueue.enqueue MyJob.new\n```\n\nBBQue jobs need to fulfill the following interface:\n\n1. The object contains an instance method `#work` without any arguments\n2. The object (instance) must be serializable via `Marshal.dump` and `Marshal.load`\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'bbque'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install bbque\n\n## Usage\n\nBBQue is using Redis. Therefore, you have to install Redis first.\n\n### Producer\n\nTo enqueue a job, you need a Producer instance:\n\n```ruby\nSomeQueue = BBQue::Producer.new(\"default\")\n```\n\nwhere `default` is the queue name. You can additionally pass a delay, priority\n(-512 ... 512, higher is better, default is 0), logger and/or the Redis instance:\n\n```ruby\nSomeQueue = BBQue::Producer.new(\"default\", delay: 2.hours, pri: 20, redis: Redis.new, logger: Logger.new(...))\n```\n\nThen enqueue a job:\n\n```ruby\nSomeQueue.enqueue MyJob.new(\"Some argument\")\n```\n\nwhere `MyJob` looks like:\n\n```ruby\nclass MyJob\n  attr_accessor :argument\n\n  def initialize(argument)\n    self.argument = argument\n  end\n\n  def work\n    # Do some work\n  end\nend\n```\n\n### Consumer\n\nTo process the enqueued jobs, create a file, e.g. jobs.rb:\n\n```ruby\nBBQue::Consumer.new(\"default\").run\n```\n\nand run it via:\n\n    $ bbque jobs.rb\n\nBBQue will loop through all the jobs, run them, and will then wait for new\nones (no polling). You can pass the queue name, the Redis instance and a logger.\n\n```ruby\nBBQue::Consumer.new([\"default\", \"important\"], logger: ..., redis: ...).run\n```\n\n### Forking Consumers\n\nBy default, BBQue does not fork a process for every job, but\nit already ships with the ability to do so.\n\nTo make BBQue fork, create a custom consumer:\n\n```ruby\nclass ForkingConsumer \u003c BBQue::Consumer\n  def fork?\n    true\n  end\n\n  def before_fork\n    # ...\n  end\n\n  def after_fork\n    # ...\n  end\nend\n```\n\nThen, start your custom consumer in favor of BBQue's default one:\n\n```ruby\nForkingConsumer.new([\"queue1\", \"queue2\", ...], ...).run\n```\n\n## Job Limit\n\nYou can specify a `limit` for a job, such that no more than `limit` instances\nof the same job can be concurrently enqueued. You need to pass a `job_key` as\nwell, such that BBQue can determine duplicate jobs:\n\n```ruby\nMyQueue.enqueue MyJob.new, limit: 1, job_key: \"my_singleton_job\"\n```\n\n\n## Delay/Scheduler\n\nYou can enqueue jobs while specifing a delay:\n\n```ruby\nMyQueue.enqueue MyJob.new, delay: 60\n```\n\nWhen using `delay`, jobs are added to a special queue, such that\nyou need to start a scheduler process, which regularly checks for\ndelayed jobs, checks whether the delay has passed and subsequently\nmoves the jobs from the delay queue to its target queue.\n\n```ruby\nBBQue::Scheduler.new(redis: Redis.new, logger: Rails.logger).run\n```\n\n## Safety\n\nRegarding Redis issues, BBQue implements job safety measures similar to sidekiq\npro's `super_fetch`. BBQue is using `BRPOPLPUSH` and when a job is fetched, it\nis added to a `processing` queue, such that lost jobs get rescued on worker\nrestart.\n\nBBQue, howoever, doesn't offer any retry mechanisms for failed jobs, ie jobs\nraising exceptions. You are responsible for rescuing exceptions within your\njobs and taking appropriate measures.\n\n## Graceful Termination\n\nYou can stop a worker gracefully by sending a QUIT, TERM, INT or USR2 signal to\nit. The worker will finish its current job and terminate afterwards.\n\n## Contributing\n\n1. Fork it ( https://github.com/mrkamel/bbque/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkamel%2Fbbque","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrkamel%2Fbbque","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkamel%2Fbbque/lists"}