0.0
No commit activity in last 3 years
No release in over 3 years
Ost-scheduler lets you manage queues and workers with Redis.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
 Project Readme

Ost Scheduler

Ost-Scheduler is an extension to Ost that adds support for queueing items in the future.

Description

Ost provides simple, lightweight background job functionality.

Ost-Scheduler makes it easy to enqueue object ids and process them with workers.

Say you want to process video uploads. In your application you will have something like this:

Ost[:videos_to_process].push_at( Time.now + 60 , @video.id )

Then, you will have a worker that will look like this:

require "ost-scheduler"

Ost[:videos_to_process].each_delayed do |id|
  # Do something with it!
end

Usage

Ost uses a lightweight Redis client called [Redic][redic]. To connect to a Redis database, you will need to set an instance of Redic, with a URL of the form redis://:<passwd>@<host>:<port>/<db>.

You can customize the connection by calling Ost.redis=:

require "ost-scheduler"

Ost.redis = Redic.new("redis://127.0.0.1:6379")

Then you only need to refer to a queue for it to pop into existence:

require "ost-scheduler"

Ost.redis = Redic.new("redis://127.0.0.1:6379")

Ost[:event].push_at(@datetime, @feed.id)

Ost defaults to a Redic connection to redis://127.0.0.1:6379. The example above could be rewritten as:

require "ost-scheduler"

Ost[:event].push_at(@datetime, @feed.id)

A worker is a Ruby file with this basic code:

require "ost-scheduler"

Ost[:rss_feeds].each_delayed do |id|
  # ...
end

Available methods

Ost[:example].push_at(datetime, item): add item to the :example queue in a exactly datetime.

Ost[:example].each_delayed { |item| ... }: consume item from the :example queue. .

Ost.stop: halt processing for all queues.

Ost[:example].stop: halt processing for the example queue.

Installation

$ gem install ost-scheduler