Coder Social home page Coder Social logo

active_scheduler's Introduction

Gem VersionBuild Status Coveralls branchCode Climate

active_scheduler

active_scheduler is a gem to take a standard schedule one would use with resque scheduler and wraps it to work with ActiveJob.

Currently only Resque is supported, but pull requests to add other queues (sidekiq, etc) would be welcomed!

Requirements/Support

  • Ruby 2.0+
  • ActiveJob
    • 4.2 is tested and used in production
    • 5.0-6.0 is tested against CI, but I haven't tried it in production.
  • Resque
  • Resque Scheduler

Setup

Installation

Add active_scheduler to your Gemfile.

Usage

In your Resque initializer:

require 'resque/server'
require 'resque/scheduler/server'
require 'active_scheduler'

# ... Set up your Resque ...
...

yaml_schedule    = YAML.load_file("#{Rails.root}/config/resque_schedule.yaml") || {}
wrapped_schedule = ActiveScheduler::ResqueWrapper.wrap yaml_schedule
Resque.schedule  = wrapped_schedule

Example Format

simple_job:
  every: "30s"
  queue: "simple"
  class: "SimpleJob"
  args:
    -
  description: "It's a simple job."

ThisIsTheClass:
  cron: "* * * *"
  queue: 'cronny'
  description: "Will call the ThisIsTheClass class"

Only classes that are descended from ActiveJob::Base will be wrapped

Job Classes With Named Args

If you have a job class that uses named arguments you can specify that. args should be a hash nested in the array and you need to add the named_args key.

simple_job:
  every: "30s"
  queue: "simple"
  class: "SimpleJob"
  args:
    - foo: 1
      bar: 2
  description: "It's a simple job."
  named_args: true

Credits

License

MIT

active_scheduler's People

Contributors

justinaiken avatar jdguzman avatar ximus avatar amhol avatar jdatti avatar jeremycrosbie avatar r3trofitted avatar spiffystores 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.