Code Monkey home page Code Monkey logo

resque-remote's Introduction

Please note that Resque Remote depends on Resque version 0.10.0

Resque Remote is a plugin to allow remote job droppability. Try saying that 10 times fast.

Resque is great and so is queue-based job processing with redis. Resque Remote aims to provide you the ability to queue a job without having the processing class (e.g. the Job handler itself) loaded into memory.

Resque Remote's simple goal is to allow you to add a job to a queue with a string identifier for the class rather than the class constant. It is assumed that the worker-side of the equation will have the class in memory and hence will be able to run it no problem. If this isn't the case, the worker will explode in a fiery ball. Probably getting some on you as a result.

Installation

Note: You must have a version of Resque installed or added to your Gemfile for Resque Remote to work. Resque Version 0.10.0 has been tested to work with the current release of Resque Remote.

Install the gem ad-hoc:

$ gem install resque -v 0.10.0
$ gem install resque-remote

Or, add it to your Bundler Gemfile:

# Gemfile
gem 'resque', '0.10.0'
gem 'resque-remote'

And then run a bundle install.

Without Bundler, in your appropriate config location for your app:

require 'resque'
require 'resque-remote'

If you're using bundler, just setup your gemset normally.

Usage

(De)Queueing

To queue a job, tell resque to remote_enqueue your job by passing the string representation of your job's class name, the name of the queue to use, and whatever parameters are appropriate for the job.

Resque.remote_enqueue('MyJobClass', :low_priority, param1, param2, ...)

To dequeue, call remote_dequeue instead:

Resque.remote_dequeue('MyJobClass', :low_priority, param1, param2, ...)

Worker processing

Resque Remotes purpose is to make remote job processing doable. Hence, your workers won't be running the same application code that actually queued the job for you in the first place. So, assuming I queued the jobs from above, your separate application should have an implementing class that your workers have access to.

Note that the queue this job belongs to isn't defined in our job class because it's metadata that Resque uses when it first queues the job, which we've already done. So, no @queue = :low_priority needed here.

class MyJobClass
	# no queue needed
	
	def self.perform(param1, param2)
		# ... process the job herre
	end
end

Errata

Feedback, comments and questions are welcome at bj [dot] neilsen [at] gmail [dot] com.

resque-remote's People

Contributors

localshred avatar

Stargazers

 avatar

Watchers

 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.