Project

postpone

0.0
No commit activity in last 3 years
No release in over 3 years
Beanstalkd backed asynchronous priority queue
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Postpone

A Beanstalkd backed asynchronous priority queue.

Why beanstalkd?

In contrast to other asynchronous priority queues Beanstalkd doesn't use
polling behind the scene. This means that your jobs will start faster.

Installation

Add this line to your application's Gemfile:

gem "postpone"

And then execute:

$ bundle

Or install it yourself as:

$ gem install postpone

Don't forget to install and start the beanstalkd bin.

Invoke

Call postpone on any given object to postpone the execution.

User.first.postpone.notify!

Postpone cannot postpone blocks. Why is explained here.

User.first.postpone.notify! { "How do you do?" }

Worker

Postpone is build on top of beanstalkd and stalker which means that you need an external worker.

Creating a worker

Create a file called jobs.rb and add the following code to it

require "postpone/worker"

Add your own worker to the same file, if you have any.
Take a look at the official stalker repo for more information.

Stalker::job "email.send" do |args|
  Pony.send(to: args['to'], subject: "Hello there")
end

Start your worker using stalk jobs.rb

Hint

Keep in mind that the object you are trying to postpone needs to be available on both sides. So if you're trying to postpone an operation on a rails object you need to load the rails environment on the worker side too.

# Loading rails
require File.expand_path("../environment", __FILE__)

# Loading postpone
require "postpone/worker"

Alternatives

Testing

Start by installing rspec.
Then, run the tests using rspec .

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Postpone is released under the MIT License.