GithubHelp home page GithubHelp logo

strobemonkey / job_queue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mloughran/job_queue

2.0 2.0 0.0 97 KB

JobQueue means you don't have to worry about your queue no more!

Home Page: http://github.com/mloughran/job_queue/

License: MIT License

Ruby 100.00%

job_queue's Introduction

JobQueue

job_queue allows you to use lots of message queues with exactly the same interface so you don't need to worry about which queue to pick :)

This should get you started:

require 'rubygems'
require 'job_queue'

Before you can do anything you must specify an adapter to use

JobQueue.adapter = JobQueue::BeanstalkAdapter.new

Jobs can then be simply added to the queue

JobQueue.put("flubble bubble")

In your workers you'll want to subscribe to a queue

JobQueue.subscribe do |job|
  puts job
end

This subscribe block takes care of waiting for the next job to arrive and the block is passed exactly what you passed in. If you want to exit the loop just throw :stop.

JobQueue.subscribe do |job|
  # Wait - I changed my mind!
  throw :stop
end

What should you put on the queue

You might love Ruby right now, but why lock yourself in? Often the kinds of things you use queues for are the kind of things you'll want to optimize. This is a good place to start:

JSON.generate({:some => "hash"})
JSON.parse(job)

Can you show me a nice processing daemon?

Yes. Just a minute...

Adapters

Take your pick! Right now we have:

Beanstalk

http://xph.us/software/beanstalkd/

AMQP

http://github.com/tmm1/amqp/

You need to run all your code within an eventmachine loop to use AMQP.

Starling

http://github.com/starling/starling/

job_queue's People

Contributors

mloughran avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.