Project

fleiss

0.01
Low commit activity in last 3 years
No release in over a year
Run background jobs with your favourite stack.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Fleiss

Test License

Minimialist background jobs backed by ActiveJob and ActiveRecord.

Usage

Define your active jobs, as usual:

class SimpleJob < ActiveJob::Base
  queue_as :default

  def perform(*args)
    # Perform Job
  end
end

Allow jobs to expire job by specifying an optional TTL:

class ExpringJob < ActiveJob::Base
  queue_as :default
  retry_on SomeError, attempts: 1_000_000

  def perform(*args)
    # Perform Job
  end

  # This will cause the job to retry up-to 1M times
  # until the 72h TTL is reached.
  def ttl
    72.hours
  end
end

Allow to subscribe on worker perform method and detect errors

ActiveSupport::Notifications.subscribe('worker_perform.fleiss') do |event|
  break unless event.payload.key?(:exception_object)

  Raven.capture_exception(event.payload[:exception_object])
end

Include the data migration:

# db/migrate/20182412102030_create_fleiss_jobs.rb
require 'fleiss/backend/active_record/migration'

class CreateFleissJobs < ActiveRecord::Migration[5.2]
  def up
    Fleiss::Backend::ActiveRecord::Migration.migrate(:up)
  end

  def down
    Fleiss::Backend::ActiveRecord::Migration.migrate(:down)
  end
end

Run the worker:

bundle exec fleiss -I . -r config/environment