{"id":13880195,"url":"https://github.com/fnando/qe","last_synced_at":"2025-07-16T16:31:19.438Z","repository":{"id":5419279,"uuid":"6610535","full_name":"fnando/qe","owner":"fnando","description":"A simple interface over several background job libraries like Resque, Sidekiq and DelayedJob.","archived":true,"fork":false,"pushed_at":"2015-02-03T16:56:25.000Z","size":261,"stargazers_count":101,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-03T04:47:20.370Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnando.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}},"created_at":"2012-11-09T08:22:31.000Z","updated_at":"2024-10-18T13:59:00.000Z","dependencies_parsed_at":"2022-07-06T16:34:11.177Z","dependency_job_id":null,"html_url":"https://github.com/fnando/qe","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/fnando/qe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fqe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fqe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fqe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fqe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/qe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Fqe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265524630,"owners_count":23782016,"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-08-06T08:02:51.333Z","updated_at":"2025-07-16T16:31:19.120Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","readme":"# Qe\n\nA simple interface over several background job libraries like Resque, Sidekiq and DelayedJob.\n\n## Usage\n\nIn this wild world where a new asynchronous job processing\nlibrary is released every once in a while, Qe tries to keep a unified\ninterface that works with the most famous libraries:\n\n* [Sidekiq](http://mperham.github.com/sidekiq/)\n* [Resque](https://github.com/defunkt/resque/)\n* [DelayedJob](https://github.com/collectiveidea/delayed_job)\n* [Qu](https://github.com/bkeepers/qu)\n* [Beanstalk](https://github.com/kr/beanstalkd)/[Backburner](http://nesquena.github.com/backburner/)\n\nTo set the adapter, just load the file according to your adapter:\n\n``` ruby\nrequire \"qe/resque\"\nrequire \"qe/qu\"\nrequire \"qe/delayed_job\"\nrequire \"qe/beanstalk\"\n```\n\nYou also need to require the library you're going to use. If you're using Rails with Bundler, you can simple require the correct file and dependency.\n\n``` ruby\nsource :rubygems\ngem \"rails\", \"3.2.8\"\n\ngem \"sidekiq\"\ngem \"qe\", :require =\u003e \"qe/sidekiq\"\n\ngem \"resque\"\ngem \"qe\", :require =\u003e \"qe/resque\"\n\ngem \"qu\"\ngem \"qe\", :require =\u003e \"qe/qu\"\n\ngem \"backburner\"\ngem \"qe\", :require =\u003e \"qe/beanstalk\"\n```\n\nCreate a worker that will send e-mails through `ActionMailer`.\n\n``` ruby\nclass MailerWorker\n  include Qe::Worker\n\n  def perform\n    Mailer.public_send(options[:mail], options).deliver\n  end\nend\n```\n\nDefine our `Mailer` class.\n\n``` ruby\nclass Mailer \u003c ActionMailer::Base\n  def welcome(options)\n    @options = options\n    mail :to =\u003e options[:email]\n  end\nend\n```\n\nEnqueue a job to be processed asynchronously.\n\n``` ruby\nMailerWorker.enqueue({\n  :mail =\u003e :welcome,\n  :email =\u003e \"john@example.org\",\n  :name =\u003e \"John Doe\"\n})\n```\n\nYou can specify when this job must be processed by setting the `:run_at` option.\n\n``` ruby\nMailerWorker.enqueue({\n  :mail =\u003e :follow_up,\n  :email =\u003e \"john@example.org\",\n  :name =\u003e \"John Doe\",\n  :run_at =\u003e 5.days.from_now\n})\n```\n\n### Setting the queue name\n\nSometimes setting the queue name is important.\n\n```ruby\nclass HelloWorker\n  include Qe::Worker\n\n  queue :hello\nend\n```\n\n### Defining actions\n\nSometimes you want to create several actions in a single worker, just because is easier. Instead of manually dispatch the action on your perform method, you can\njust add the `Qe::Action` module.\n\n``` ruby\nclass NotificationWorker\n  include Qe::Worker\n  include Qe::Action\n\n  def shutdown\n    puts options[:message]\n  end\n\n  def startup\n    puts options[:message]\n  end\n\n  def default\n    puts options[:message]\n  end\nend\n```\n\nNow, you can just enqueue jobs by defining the `:action` option. If no action is defined, then the default is executed.\n\n``` ruby\nNotificationWorker.enqueue(:action =\u003e :shutdown, :message =\u003e \"shutting down\")\nNotificationWorker.enqueue(:action =\u003e :startup, :message =\u003e \"starting up\")\nNotificationWorker.enqueue(:message =\u003e \"wat?\")\n```\n\nThe action must be a existing public method. If not defined, `Qe::Action::MissingActionError` exception is raised.\n\n### Working with I18n\n\nWhen you're working in internationalized app, you need to perform some jobs with the correct locale set (sending an e-mail, maybe?). Instead of doing it manually, you can just use the `Qe::Locale` extension.\n\nThis extension will set the `:locale` option when you enqueue some job and set it to `I18n.locale` when you perform it. Just include it after the `Qe::Worker` module.\n\n``` ruby\nclass MailerWorker\n  include Qe::Worker\n  include Qe::Locale\n\n  def perform\n    Mailer.public_send(options[:mail], options).deliver\n  end\nend\n```\n\nThis approach is good enough, but if you're using ActionMailer, try the `Qe::ActionMailer` instead, combining this extension as well.\n\n### ActionMailer integration\n\nQe comes with an extension to send e-mails through ActionMailer. You can set the mailer and which mail will be sent.\n\n```ruby\nclass Mailer \u003c ActionMailer::Base\n  def welcome(options)\n    @options = options\n    mail :to =\u003e options[:email]\n  end\nend\n\nclass MailerWorker\n  include Qe::Worker\n  include Qe::ActionMailer\n  include Qe::Locale\n\n  def mailer\n    Mailer\n  end\nend\n\nMailerWorker.enqueue(\n  :mail =\u003e :welcome,\n  :name =\u003e \"John Doe\",\n  :email =\u003e \"john@example.org\"\n)\n```\n\nIf the `mailer()` method isn't defined, the `Qe::ActionMailer::AbstractMethodError` exception will be raised.\n\nIf the `:mail` option isn't defined, the `Qe::ActionMailer::MissingMailNameError` exception will be raised.\n\n### Sidekiq\n\nYou can set Sidekiq options by using the method `Sidekiq::Worker.options`.\n\n```ruby\nrequire 'qe/sidekiq'\n\nclass NonRetryableWorker\n  include Qe::Worker\n  options retry: false\n\n  def perform\n    # do something...\n  end\nend\n```\n\n### Development support\n\nQe comes with development support. Instead of starting up workers on development environment, you can use the `Qe::Immediate` adapter, which executes your worker right away!\n\n``` ruby\nQe.adapter = Qe::Immediate\n```\n\nIf you're using Rails, you can add the line above to your `config/environments/development.rb` file.\n\n### Testing support\n\nQe also comes with testing support. Just require the `qe/testing.rb` file\nand a fake queuing adapter will be used. All enqueued jobs will be stored\nat `Qe.jobs`. Note that this method is only available on testing mode.\n\n``` ruby\nrequire \"qe/testing\"\nQe.adapter = Qe::Testing\n```\n\nIf you are using RSpec, you can require the `qe/testing/rspec.rb` file\ninstead. This will reset `Qe.jobs` before every spec and will add a\n`enqueue` matcher.\n\n``` ruby\n# Add the following like to your spec_helper.rb file\nrequire \"qe/testing/rspec\"\n\ndescribe \"Enqueuing a job\" do\n  it \"enqueues job\" do\n    expect {\n      # do something\n    }.to enqueue(MailerWorker).with(:email =\u003e \"john@example.org\")\n  end\nend\n```\n\n## Maintainer\n\n* Nando Vieira (\u003chttp://nandovieira.com.br\u003e)\n\n## License:\n\n(The MIT License)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fqe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Fqe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Fqe/lists"}