Project

pg_jobs

0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Simple ActiveJob queue for PostgreSQL using LISTEN/NOTIFY
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.9.0
~> 0.59.1
~> 0.16.1

Runtime

< 2.0, >= 0.18
< 6.0, >= 5.1
 Project Readme

Gem license MIT build maintainability coverage docs

PgJobs

Simple Active Job worker for PostgreSQL using LISTEN/NOTIFY and SKIP LOCKED.

Supports most Active Job features like multiple queues, priorities and wait times.

Dependencies

  • PostgreSQL >= 9.5 to use SKIP LOCKED
  • Ruby >= 2.3
  • Rails >= 5.1

Installation

Add this line to your application's Gemfile:

gem 'pg_jobs'

And then execute:

bundle

Then copy the migrations and migrate your database:

bin/rails pg_jobs_engine:install:migrations
bin/rails db:migrate

To configure the Active Job adapter add this to your environment configuration (config/environments/production.rb):

config.active_job.queue_adapter = :pg_jobs

If you want to run all your jobs in one queue, we recommend to configure ActionMailer to use the default queue:

config.action_mailer.deliver_later_queue_name = 'default'

Configuration

You can set the logger for pg_jobs with PgJobs.logger=:

PgJobs.logger = Logger.new(STDOUT)
PgJobs.logger.level = :debug

It will use ActiveJob::Base.logger by default.

Note: This does not change the logging behaviour of your jobs, only the log statements of pg_jobs itself.

Usage

Just schedule your work with Active Job, then run one or multiple workers for the default queue with

bin/rails runner PgJobs.work

or for other queues with

bin/rails runner "PgJobs.work(:my_queue)"

For more documentation about Active Job and how to use different queues, scheduled jobs, priorities and error handling, see the Active Job Rails Guide.

Contributing

Use Github issues and pull requests.

License

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