MidgetJobs is simple implementation of background jobs for Ruby on Rails. I does not meant to be used without it. It is connected to ActiveJob and PostgreSQL using its triggers, notifications and listening.
There is new column runner in midget_jobs table! It is used to recognise who will run particular job (if there are multiple application over one database)
I added new configuration to Initializer. Add this to your config/initializers/midget_jobs.rb
Rails.application.config.x.midget_jobs.runner = Rails.application.class.parent_name
Please create migration with generator
rails generate migration AddRunnerToMidgetJob runner:string:index
Add this line to your application's Gemfile:
gem 'midget_jobs'
And then execute:
$ bundle
Then run
$ rails generate midget_jobs:install
This generator creates an initializer file at config/initializers and migrations to db/migrate
In file config/initializers/midget_jobs.rb
disable start with puma:
...
if Rails.const_defined?('Server')# || $0.include?('puma')
In file config/puma/production.rb
update on_worker_boot do
block as:
...
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
Rails.logger.debug 'on_worker_boot starting jobs'
MidgetJobs.initialize_workers
...
end
Just use ActiveJob as described in Guides
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Bug reports and pull requests are welcome on GitHub at https://github.com/jchsoft/midget_jobs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the MidgetJob project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.