resque-scheduler 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,7 +1,7 @@
1
1
  resque-scheduler
2
2
  ===============
3
3
 
4
- Resque-scheduler is an extension to Resque that adds support for queueing items
4
+ Resque-scheduler is an extension to [Resque](http://github.com/defunkt/resque) that adds support for queueing items
5
5
  in the future.
6
6
 
7
7
  Requires redis >=1.1.
@@ -38,8 +38,8 @@ is most likely stored in a YAML like so:
38
38
 
39
39
  And then set the schedule wherever you configure Resque, like so:
40
40
 
41
- require 'resque-scheduler'
42
- ResqueScheduler.schedule = YAML.load_file(File.join(File.dirname(__FILE__), '../resque_schedule.yml'))
41
+ require 'resque_scheduler'
42
+ Resque.schedule = YAML.load_file(File.join(File.dirname(__FILE__), '../resque_schedule.yml'))
43
43
 
44
44
  Keep in mind, scheduled jobs behave like crons: if your scheduler process (more
45
45
  on that later) is not running when a particular job is supposed to be queued,
@@ -98,20 +98,24 @@ The Delayed tab:
98
98
  ![The Delayed Tab](http://img.skitch.com/20100111-ne4fcqtc5emkcuwc5qtais2kwx.jpg)
99
99
 
100
100
 
101
- The Scheduler process
102
- ---------------------
101
+ Installation and the Scheduler process
102
+ --------------------------------------
103
103
 
104
- The scheduler process is just a rake task which is responsible for both queueing
105
- items from the schedule and polling the delayed queue for items ready to be
106
- pushed on to the work queues. For obvious reasons, this process never exits.
104
+ To install:
107
105
 
108
- $ rake resque-scheduler
106
+ gem install resque-scheduler
109
107
 
110
108
  You'll need to add this to your rakefile:
111
109
 
112
110
  require 'resque_scheduler/tasks'
113
111
  task "resque:setup" => :environment
114
112
 
113
+ The scheduler process is just a rake task which is responsible for both queueing
114
+ items from the schedule and polling the delayed queue for items ready to be
115
+ pushed on to the work queues. For obvious reasons, this process never exits.
116
+
117
+ $ rake resque-scheduler
118
+
115
119
  Supported environment variables are `VERBOSE` and `MUTE`. If either is set to
116
120
  any nonempty value, they will take effect. `VERBOSE` simply dumps more output
117
121
  to stdout. `MUTE` does the opposite and silences all output. `MUTE` supercedes
@@ -130,4 +134,4 @@ work on resque-scheduler.
130
134
  Contributing
131
135
  ------------
132
136
 
133
- For bugs or suggestions, please just open an issue in github.
137
+ For bugs or suggestions, please just open an issue in github.
@@ -60,18 +60,22 @@ module Resque
60
60
  # Handles queueing delayed items
61
61
  def handle_delayed_items
62
62
  item = nil
63
- if timestamp = Resque.next_delayed_timestamp
64
- item = nil
65
- begin
66
- handle_shutdown do
67
- if item = Resque.next_item_for_timestamp(timestamp)
68
- log "queuing #{item['class']} [delayed]"
69
- klass = constantize(item['class'])
70
- Resque.enqueue(klass, *item['args'])
63
+ begin
64
+ if timestamp = Resque.next_delayed_timestamp
65
+ item = nil
66
+ begin
67
+ handle_shutdown do
68
+ if item = Resque.next_item_for_timestamp(timestamp)
69
+ log "queuing #{item['class']} [delayed]"
70
+ klass = constantize(item['class'])
71
+ Resque.enqueue(klass, *item['args'])
72
+ end
71
73
  end
72
- end
73
- end while !item.nil?
74
- end
74
+ # continue processing until there are no more ready items in this timestamp
75
+ end while !item.nil?
76
+ end
77
+ # continue processing until there are no more ready timestamps
78
+ end while !timestamp.nil?
75
79
  end
76
80
 
77
81
  def handle_shutdown
@@ -57,12 +57,12 @@ module ResqueScheduler
57
57
  # Now, add this timestamp to the zsets. The score and the value are
58
58
  # the same since we'll be querying by timestamp, and we don't have
59
59
  # anything else to store.
60
- redis.zset_add :delayed_queue_schedule, timestamp.to_i, timestamp.to_i
60
+ redis.zadd :delayed_queue_schedule, timestamp.to_i, timestamp.to_i
61
61
  end
62
62
 
63
63
  # Returns an array of timestamps based on start and count
64
64
  def delayed_queue_peek(start, count)
65
- (redis.zrange :delayed_queue_schedule, start, start+count).collect(&:to_i)
65
+ redis.zrange(:delayed_queue_schedule, start, start+count).collect(&:to_i)
66
66
  end
67
67
 
68
68
  # Returns the size of the delayed queue schedule
@@ -1,3 +1,3 @@
1
1
  module ResqueScheduler
2
- Version = '1.0.0'
2
+ Version = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben VandenBos
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-11 00:00:00 -08:00
12
+ date: 2010-02-01 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency