sidetiq 0.4.0.rc4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ead5ee1ca94f1b13e80313b412a3814dd7d281a2
4
- data.tar.gz: f8e034df1e712bcc81b3f203933c847d0ad4511b
3
+ metadata.gz: d9aeea39b2397a68571939038f6aa704d7d82ea2
4
+ data.tar.gz: 96f94bd883e67ecab0d63ce4a7afaa655e67fa00
5
5
  SHA512:
6
- metadata.gz: 8df443743d71f5c258ece23af07a1f535d248d6ded6bfacf9b45c57a524ff4fa49d6a8be22960e83fc08c8aefcec556e644a9c26055b18e143a7b12a6d6c9f5a
7
- data.tar.gz: 30fe0fe1972f3cd6d65836c62c18d711da3a8364aa0c37a725d465320593ed899337b0096fc78ce47e9acca6f2783c9f8252a4dbd7eb7cf406609dde1ac14c4a
6
+ metadata.gz: 24a9e7de6f0e33660867a0eaab73139a0509339e0e34b0691656026a671a8ef0aea4bd01522660b457146339a908fe7a583782d26b2d5d9000b4c24fe07f804e
7
+ data.tar.gz: 1913b8bd90640e4a0574b6b7555fd7c601b23b03bf4ac9d8ccfc4594393ad4b24d6d28d3959b7a7d899c92b2a3a73ec32e18260650ecceae3b4d5d05907e6145
data/README.md CHANGED
@@ -8,337 +8,30 @@ Sidetiq
8
8
 
9
9
  Recurring jobs for [Sidekiq](http://mperham.github.com/sidekiq/).
10
10
 
11
- Table Of Contents
12
- -----------------
13
-
14
- * [Overview](#section_Overview)
15
- * [Dependencies](#section_Dependencies)
16
- * [Installation](#section_Installation)
17
- * [Introduction](#section_Introduction)
18
- * [Backfills](#section_Backfills)
19
- * [Configuration](#section_Configuration)
20
- * [Logging](#section_Configuration_Logging)
21
- * [API](#section_API)
22
- * [Polling](#section_Polling)
23
- * [Known Issues](#section_Known_Issues)
24
- * [Web Extension](#section_Web_Extension)
25
- * [Contribute](#section_Contribute)
26
- * [License](#section_License)
27
- * [Author](#section_Author)
28
-
29
- <a name='section_Overview'></a>
30
11
  Overview
31
12
  --------
32
13
 
33
14
  Sidetiq provides a simple API for defining recurring workers for Sidekiq.
34
15
 
35
- - Cuncurrency using Celluloid actors.
16
+ - Cuncurrency and fault-tolerance using Celluloid actors.
36
17
 
37
18
  - Flexible DSL based on [ice_cube](http://seejohnrun.github.com/ice_cube/)
38
19
 
39
- - Sidetiq uses a locking mechanism (based on watch/multi/psetex/exec) internally
40
- so Sidetiq clocks can run in each Sidekiq process without interfering with
41
- each other (tested with sub-second polling of scheduled jobs by Sidekiq and
42
- Sidetiq clock rates above 100hz).
43
-
44
- Detailed API documentation is available on [rubydoc.info](http://rdoc.info/github/tobiassvn/sidetiq/).
45
-
46
- <a name='section_Dependencies'></a>
47
- Dependencies
48
- ------------
49
-
50
- - [Sidekiq](http://mperham.github.com/sidekiq/)
51
- - [Celluloid](http://celluloid.io/) (shared with Sidekiq)
52
- - [ice_cube](http://seejohnrun.github.com/ice_cube/)
53
-
54
- <a name='section_Installation'></a>
55
- Installation
56
- ------------
57
-
58
- The best way to install Sidetiq is with RubyGems:
59
-
60
- $ [sudo] gem install sidetiq
61
-
62
- If you're installing from source, you can use [Bundler](http://gembundler.com/)
63
- to pick up all the gems ([more info](http://gembundler.com/bundle_install.html)):
64
-
65
- $ bundle install
66
-
67
- <a name='section_Introduction'></a>
68
- Introduction
69
- ------------
70
-
71
- Defining recurring jobs is simple:
72
-
73
- ```ruby
74
- class MyWorker
75
- include Sidekiq::Worker
76
- include Sidetiq::Schedulable
77
-
78
- # Daily at midnight
79
- recurrence { daily }
80
-
81
- def perform
82
- # do stuff ...
83
- end
84
- end
85
- ```
86
-
87
- It also is possible to define multiple scheduling rules for a worker:
88
-
89
- ```ruby
90
- class MyWorker
91
- include Sidekiq::Worker
92
- include Sidetiq::Schedulable
93
-
94
- recurrence do
95
- # Every third year in March
96
- yearly(3).month_of_year(:march)
97
-
98
- # Every second year in February
99
- yearly(2).month_of_year(:february)
100
- end
101
-
102
- def perform
103
- # do stuff ...
104
- end
105
- end
106
- ```
107
-
108
- Or complex schedules:
109
-
110
- ```ruby
111
- class MyWorker
112
- include Sidekiq::Worker
113
- include Sidetiq::Schedulable
114
-
115
- # Every other month on the first monday and last tuesday at 12 o'clock.
116
- recurrence { monthly(2).day_of_week(1 => [1], 2 => [-1]).hour_of_day(12) }
117
-
118
- def perform
119
- # do stuff ...
120
- end
121
- end
122
- ```
123
-
124
- Additionally, the last and current occurrence time (as a `Float`) can be
125
- passed to the worker simply by adding arguments to `#perform`. Sidetiq
126
- will check the method arity before enqueuing the job:
127
-
128
- ```ruby
129
- class MyWorker
130
- include Sidekiq::Worker
131
- include Sidetiq::Schedulable
132
-
133
- recurrence { daily }
134
-
135
- # Receive last and current occurrence times.
136
- def perform(last_occurrence, current_occurrence)
137
- # do stuff ...
138
- end
139
- end
140
- ```
141
-
142
- If Sidekiq is running in server-mode, Sidekiq will handle recurring
143
- jobs automatically.
144
-
145
- <a name='section_Backfills''></a>
146
- Backfills
147
- ---------
148
-
149
- In certain cases it is desirable that missed jobs will be enqueued
150
- retroactively, for example when a critical, hourly job isn't run due to
151
- server downtime. To solve this, `#recurrence` takes a *backfill* option. If
152
- missing job occurrences have been detected, Sidetiq will then enqueue
153
- the jobs automatically. It will also ensure that the timestamps passed to
154
- `#perform` are as expected:
155
-
156
- ```ruby
157
- class MyWorker
158
- include Sidekiq::Worker
159
- include Sidetiq::Schedulable
160
-
161
- recurrence backfill: true do
162
- hourly
163
- end
164
-
165
- def perform(last_occurrence, current_occurrence)
166
- # do stuff ...
167
- end
168
- end
169
- ```
170
-
171
- <a name='section_Configuration'></a>
172
- Configuration
173
- -------------
174
-
175
- ```ruby
176
- Sidetiq.configure do |config|
177
- # Clock tick resolution in seconds (default: 1).
178
- config.resolution = 0.5
179
-
180
- # Clock locking key expiration in ms (default: 1000).
181
- config.lock_expire = 100
182
-
183
- # When `true` uses UTC instead of local times (default: false)
184
- config.utc = false
185
-
186
- # Scheduling handler pool size (default: number of CPUs)
187
- config.handler_pool_size = 5
188
- end
189
- ```
190
- <a name='section_Configuration_Logging'></a>
191
- ### Logging
192
-
193
- By default Sidetiq uses Sidekiq's logger. However, this is configuration:
194
-
195
- ```ruby
196
- Sidetiq.logger = Logger.new(STDOUT)
197
- ```
198
-
199
- The logger should implement Ruby's [Logger API](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html).
200
-
201
- <a name='section_API'></a>
202
- API
203
- ---
204
-
205
- Sidetiq implements a simple API to support reflection of recurring jobs at
206
- runtime:
207
-
208
- `Sidetiq.schedules` returns a `Hash` with the `Sidekiq::Worker` class as the
209
- key and the Sidetiq::Schedule object as the value:
210
-
211
- ```ruby
212
- Sidetiq.schedules
213
- # => { MyWorker => #<Sidetiq::Schedule> }
214
- ```
215
-
216
- `Sidetiq.workers` returns an `Array` of all workers currently tracked by
217
- Sidetiq (workers which include `Sidetiq::Schedulable` and a `.recurrence`
218
- call):
219
-
220
- ```ruby
221
- Sidetiq.workers
222
- # => [MyWorker, AnotherWorker]
223
- ```
224
-
225
- `Sidetiq.scheduled` returns an `Array` of currently scheduled Sidetiq jobs
226
- as `Sidekiq::SortedEntry` (`Sidekiq::Job`) objects. Optionally, it is
227
- possible to pass a block to which each job will be yielded:
228
-
229
- ```ruby
230
- Sidetiq.scheduled do |job|
231
- # do stuff ...
232
- end
233
- ```
234
-
235
- This list can further be filtered by passing the worker class to `#scheduled`,
236
- either as a String or the constant itself:
237
-
238
- ```ruby
239
- Sidetiq.scheduled(MyWorker) do |job|
240
- # do stuff ...
241
- end
242
- ```
243
-
244
- The same can be done for recurring jobs currently scheduled for retries
245
- (`.retries` wraps `Sidekiq::RetrySet` instead of `Sidekiq::ScheduledSet`):
246
-
247
- ```ruby
248
- Sidetiq.retries(MyWorker) do |job|
249
- # do stuff ...
250
- end
251
- ```
252
-
253
- <a name='section_Polling'></a>
254
- Polling
255
- -------
256
-
257
- By default Sidekiq uses a 15 second polling interval to check if scheduled
258
- jobs are due. If a recurring job has to run more often than that you should
259
- lower this value.
260
-
261
- ```ruby
262
- Sidekiq.options[:poll_interval] = 1
263
- ```
264
-
265
- More information about this can be found in the
266
- [Sidekiq Wiki](https://github.com/mperham/sidekiq/wiki/Scheduled-Jobs).
267
-
268
- <a name='section_Known_Issues'></a>
269
- Known Issues
270
- ------------
271
-
272
- Unfortunately, using ice_cube's interval methods is terribly slow on
273
- start-up (it tends to eat up 100% CPU for quite a while). This is due to it
274
- calculating every possible occurrence since the schedule's start time. The way
275
- around is to avoid using them.
276
-
277
- For example, instead of defining a job that should run every 15 minutes like this:
278
-
279
- ```ruby
280
- class MyWorker
281
- include Sidekiq::Worker
282
- include Sidetiq::Schedulable
283
-
284
- recurrence { minutely(15) }
285
- end
286
- ```
287
-
288
- It is better to use the more explicit way:
289
-
290
- ```ruby
291
- class MyWorker
292
- include Sidekiq::Worker
293
- include Sidetiq::Schedulable
294
-
295
- recurrence { hourly.minute_of_hour(0, 15, 30, 45) }
296
- end
297
- ```
298
-
299
- <a name='section_Web_Extension'></a>
300
- Web Extension
301
- -------------
302
-
303
- Sidetiq includes an extension for Sidekiq's web interface. It will not be
304
- loaded by default, so it will have to be required manually:
305
-
306
- ```ruby
307
- require 'sidetiq/web'
308
- ```
309
-
310
- ### SCREENSHOT
311
-
312
- ![Screenshot](http://f.cl.ly/items/1P2u1v091F3V1n381g2I/Screen%20Shot%202013-02-01%20at%2012.16.17.png)
313
-
314
- <a name='section_Contribute'></a>
315
- Contribute
316
- ----------
317
-
318
- If you'd like to contribute to Sidetiq, start by forking my repo on GitHub:
20
+ - Distributed, Redis-based locking to synchronize multiple Sidetiq processes.
319
21
 
320
- [http://github.com/tobiassvn/sidetiq](http://github.com/tobiassvn/sidetiq)
22
+ - Web extension with extensive monitoring of recurring jobs.
321
23
 
322
- To get all of the dependencies, install the gem first. The best way to get
323
- your changes merged back into core is as follows:
24
+ Usage
25
+ -----
324
26
 
325
- 1. Clone down your fork
326
- 1. Create a thoughtfully named topic branch to contain your change
327
- 1. Write some code
328
- 1. Add tests and make sure everything still passes by running `rake`
329
- 1. If you are adding new functionality, document it in the README
330
- 1. Do not change the version number, I will do that on my end
331
- 1. If necessary, rebase your commits into logical chunks, without errors
332
- 1. Push the branch up to GitHub
333
- 1. Send a pull request to the tobiassvn/sidetiq project.
27
+ Please see the [Sidetiq wiki](http://github.com/tobiassvn/sidetiq/wiki) for more detailed
28
+ documentation and usage notes.
334
29
 
335
- <a name='section_License'></a>
336
30
  License
337
31
  -------
338
32
 
339
33
  Sidetiq is released under the 3-clause BSD. See LICENSE for further details.
340
34
 
341
- <a name='section_Author'></a>
342
35
  Author
343
36
  ------
344
37
 
@@ -15,10 +15,6 @@ module Sidetiq
15
15
  end
16
16
  end
17
17
 
18
- def start!
19
- warn "Sidetiq::Clock#start! is deprecated. Calling it is no longer required."
20
- end
21
-
22
18
  private
23
19
 
24
20
  def loop!
@@ -27,7 +23,7 @@ module Sidetiq
27
23
  end
28
24
  rescue StandardError => e
29
25
  handle_exception(e, context: 'Sidetiq::Clock#loop!')
30
- retry
26
+ raise e
31
27
  end
32
28
 
33
29
  def time
@@ -3,6 +3,14 @@ module Sidetiq
3
3
  class Clock
4
4
  include Logging
5
5
 
6
+ def self.start!
7
+ warn "Sidetiq::Clock#start! is deprecated. Calling it is no longer required."
8
+ end
9
+
10
+ def start!
11
+ warn "Sidetiq::Clock#start! is deprecated. Calling it is no longer required."
12
+ end
13
+
6
14
  # Internal: Returns a hash of Sidetiq::Schedule instances.
7
15
  attr_reader :schedules
8
16
 
@@ -14,7 +14,6 @@ module Sidetiq
14
14
  extend SubclassTracking
15
15
 
16
16
  module ClassMethods
17
- include Logging
18
17
  include SubclassTracking
19
18
 
20
19
  attr_writer :schedule
@@ -11,7 +11,7 @@ module Sidetiq
11
11
  PATCH = 0
12
12
 
13
13
  # Public: Sidetiq version suffix.
14
- SUFFIX = 'rc4'
14
+ SUFFIX = nil
15
15
 
16
16
  # Public: String representation of the current Sidetiq version.
17
17
  STRING = [MAJOR, MINOR, PATCH, SUFFIX].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidetiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.rc4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Svensson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-17 00:00:00.000000000 Z
11
+ date: 2013-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -233,9 +233,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  required_rubygems_version: !ruby/object:Gem::Requirement
235
235
  requirements:
236
- - - '>'
236
+ - - '>='
237
237
  - !ruby/object:Gem::Version
238
- version: 1.3.1
238
+ version: '0'
239
239
  requirements: []
240
240
  rubyforge_project:
241
241
  rubygems_version: 2.0.3