GithubHelp home page GithubHelp logo

isabella232 / devise-async Goto Github PK

View Code? Open in Web Editor NEW

This project forked from knapsackpro/devise-async

0.0 0.0 0.0 204 KB

Send Devise's emails in background. Supports Resque, Sidekiq, Delayed::Job and QueueClassic.

License: MIT License

Ruby 100.00%

devise-async's Introduction

Devise Async

Tag Build Status Code Climate

Devise Async provides an easy way to configure Devise to send its emails asynchronously using your preferred queuing backend.

Supported backends:

  • Resque
  • Sidekiq
  • Delayed::Job
  • QueueClassic
  • Torquebox
  • Backburner
  • Que
  • SuckerPunch

Installation

Add this line to your application's Gemfile:

gem 'devise-async'

And then execute:

$ bundle

Or install it yourself as:

$ gem install devise-async

Usage

Add :async to the devise call in your model:

class User < ActiveRecord::Base
  devise :database_authenticatable, :async, :confirmable # etc ...
end

Set your queuing backend by creating config/initializers/devise_async.rb:

# Supported options: :resque, :sidekiq, :delayed_job, :queue_classic, :torquebox, :backburner, :que, :sucker_punch
Devise::Async.backend = :resque

Tip: it defaults to Resque. You don't need to create the initializer if using it.

Advanced Options

Enabling via config

The gem can be enabled/disabled easily via config, for example based on environment.

# config/initializers/devise_async.rb
Devise::Async.enabled = true # | false

Custom mailer class

Customize Devise.mailer at will and devise-async will honor it.

Upgrade note: if you're upgrading from any version < 0.6 and getting errors trying to set Devise::Async.mailer just use Devise.mailer instead.

Custom queue

Let you specify a custom queue where to enqueue your background Devise jobs. Defaults to :mailer.

# config/initializers/devise_async.rb
Devise::Async.queue = :my_custom_queue

Custom priority

You can specify a custom priority for created background jobs in Devise or Backburner. If no value is specified, jobs will be enqueued with whatever default priority is configured in Devise or Backburner.

# config/initializers/devise_async.rb
Devise::Async.priority = 10

Setup via block

To avoid repeating Devise::Async in the initializer file you can use the block syntax similar to what Devise offers.

# config/initializers/devise_async.rb
Devise::Async.setup do |config|
  config.enabled = true
  config.backend = :resque
  config.queue   = :my_custom_queue
end

Troubleshooting

If you are using Sidekiq and your jobs are enqueued but not processed you might need to set a queue explicitly:

# config/initializers/devise_async.rb
Devise::Async.setup do |config|
  config.backend = :sidekiq
  config.queue   = :default
end

Testing

Be aware that since version 0.3.0 devise-async enqueues the background job in active record's after_commit hook. If you're using rspec's use_transactional_fixtures the jobs might not be enqueued as you'd expect.

More details in this stackoverflow thread.

Devise < 2.2

Older versions of Devise are supported in the devise_2_1 branch and in the 0.5 series of devise-async.

Please refer to that branch README for further info.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Released under the MIT License. See the LICENSE file for further details.

devise-async's People

Contributors

astjohn avatar barelyknown avatar bradpsheehan avatar denniskuczynski avatar glebm avatar jandudulski avatar jigfox avatar jperville avatar kmayer avatar mhfs avatar mkon avatar mohamagdy avatar pranas avatar rymai avatar weaksauce avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.