0.0
No commit activity in last 3 years
No release in over 3 years
ActiveJob wrapper to enable Apartment multi-tenancy for background jobs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 6.0
 Project Readme

ApartmentJob

ActiveJob support for Apartment Gem. Its a small wrapper around ActiveJob that takes care of storing the current tenant that a job is enqueued within and make sure to switch to it when the job is being processed. No need to pass around current tenant details to your background jobs.

ApartmentJob uses ActiveJob's public api for handling current tenant details, so it is not tied to any specific queuing adapter. It should work fine with all queue adapters supported by ActiveJob.

Installation

Add this line to your application's Gemfile:

gem 'apartment_job'

And then execute:

$ bundle

Or install it yourself as:

$ gem install apartment_job

Usage

That's it. Each job that is queued will also save Apartment::Tenant.current value along with it. Then when the server pops it, it will run the job within an Apartment::Tenant.switch block using the tenant that was active when the job was enqueued.

Contributing

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

License

The gem is available as open source under the terms of the MIT License.