sidetiq 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -1
- data/LICENSE +22 -18
- data/README.md +1 -4
- data/Rakefile +0 -3
- data/lib/sidetiq/clock.rb +8 -9
- data/lib/sidetiq/version.rb +1 -1
- data/lib/sidetiq.rb +0 -3
- data/sidetiq.gemspec +3 -3
- data/test/test_sidetiq.rb +8 -4
- metadata +7 -13
- data/ext/sidetiq_ext/extconf.rb +0 -4
- data/ext/sidetiq_ext/sidetiq_ext.c +0 -97
- data/ext/sidetiq_ext/sidetiq_ext.h +0 -17
- data/test/test_errors.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe87e48535b00a33d15395b564b62fce3a4ed68d
|
4
|
+
data.tar.gz: 1cb3287fdd6312b1792c11d46561b495cba27114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 040024621688bf956b27cee9f85235d348886e09d315cd07ada3c85faa991f02068a3e37b705307aac499aef0b7dc0f6cbaef498271149dab602a50e04a2a9e5
|
7
|
+
data.tar.gz: 6de537a1815d7cf3a1e3830efd36883b84a79ff034f54012d7c63ca809eddac5ec7e8315c0b291889cade9b63e4d73aa604606553c10116045c60cc79e9f65f2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
0.3.2
|
2
|
+
-----
|
3
|
+
|
4
|
+
- Fix tests to work with changes to Sidekiq::Client.
|
5
|
+
#push_old seems to expect 'at' instead of 'enqueued_at' now
|
6
|
+
- Switch from MIT to 3-clause BSD license.
|
7
|
+
- Remove C extension.
|
8
|
+
- Bump Sidekiq dependency to ~> 2.13.0.
|
9
|
+
- Ensure redis locks get unlocked in Clock#synchronize_clockworks.
|
10
|
+
|
1
11
|
0.3.1
|
2
12
|
-----
|
3
13
|
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,20 +1,24 @@
|
|
1
|
-
Copyright (
|
1
|
+
Copyright (c) 2012-2013, Tobias Svensson <tobias@musicglue.com>
|
2
|
+
All rights reserved.
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of Tobias Svensson nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
20
14
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL TOBIAS SVENSSON BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -32,9 +32,6 @@ Sidetiq provides a simple API for defining recurring workers for Sidekiq.
|
|
32
32
|
|
33
33
|
- Flexible DSL based on [ice_cube](http://seejohnrun.github.com/ice_cube/)
|
34
34
|
|
35
|
-
- High-resolution timer using `clock_gettime(3)` (or `mach_absolute_time()` on
|
36
|
-
Apple Mac OS X), allowing for accurate sub-second clock ticks.
|
37
|
-
|
38
35
|
- Sidetiq uses a locking mechanism (based on `setnx` and `pexpire`) internally
|
39
36
|
so Sidetiq clocks can run in each Sidekiq process without interfering with
|
40
37
|
each other (tested with sub-second polling of scheduled jobs by Sidekiq and
|
@@ -343,7 +340,7 @@ your changes merged back into core is as follows:
|
|
343
340
|
License
|
344
341
|
-------
|
345
342
|
|
346
|
-
Sidetiq is released under the
|
343
|
+
Sidetiq is released under the 3-clause BSD. See LICENSE for further details.
|
347
344
|
|
348
345
|
<a name='section_Author'></a>
|
349
346
|
Author
|
data/Rakefile
CHANGED
data/lib/sidetiq/clock.rb
CHANGED
@@ -67,9 +67,6 @@ module Sidetiq
|
|
67
67
|
|
68
68
|
# Public: Returns the current time used by the clock.
|
69
69
|
#
|
70
|
-
# Sidetiq::Clock uses `clock_gettime()` on UNIX systems and
|
71
|
-
# `mach_absolute_time()` on Mac OS X.
|
72
|
-
#
|
73
70
|
# Examples
|
74
71
|
#
|
75
72
|
# gettime
|
@@ -77,7 +74,7 @@ module Sidetiq
|
|
77
74
|
#
|
78
75
|
# Returns a Time instance.
|
79
76
|
def gettime
|
80
|
-
Sidetiq.config.utc ?
|
77
|
+
Sidetiq.config.utc ? Time.now.utc : Time.now
|
81
78
|
end
|
82
79
|
|
83
80
|
# Public: Starts the clock unless it is already running.
|
@@ -156,11 +153,13 @@ module Sidetiq
|
|
156
153
|
if redis.setnx(lock, 1)
|
157
154
|
Sidetiq.logger.debug "Sidetiq::Clock lock #{lock}"
|
158
155
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
156
|
+
begin
|
157
|
+
redis.pexpire(lock, Sidetiq.config.lock_expire)
|
158
|
+
yield redis
|
159
|
+
ensure
|
160
|
+
redis.del(lock)
|
161
|
+
Sidetiq.logger.debug "Sidetiq::Clock unlock #{lock}"
|
162
|
+
end
|
164
163
|
end
|
165
164
|
end
|
166
165
|
end
|
data/lib/sidetiq/version.rb
CHANGED
data/lib/sidetiq.rb
CHANGED
data/sidetiq.gemspec
CHANGED
@@ -11,14 +11,14 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.description = "Recurring jobs for Sidekiq"
|
12
12
|
gem.summary = gem.description
|
13
13
|
gem.homepage = "http://github.com/tobiassvn/sidetiq"
|
14
|
-
gem.license = "
|
14
|
+
gem.license = "3-clause BSD"
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
-
gem.extensions = [
|
20
|
+
gem.extensions = []
|
21
21
|
|
22
|
-
gem.add_dependency 'sidekiq', '~> 2.
|
22
|
+
gem.add_dependency 'sidekiq', '~> 2.13.0'
|
23
23
|
gem.add_dependency 'ice_cube', '~> 0.11.0'
|
24
24
|
end
|
data/test/test_sidetiq.rb
CHANGED
@@ -23,7 +23,8 @@ class TestSidetiq < Sidetiq::TestCase
|
|
23
23
|
|
24
24
|
def test_scheduled
|
25
25
|
SimpleWorker.perform_at(Time.local(2011, 1, 1, 1))
|
26
|
-
|
26
|
+
hash = SimpleWorker.jobs.first
|
27
|
+
Sidekiq::Client.push_old(hash.merge("at" => hash["enqueued_at"]))
|
27
28
|
|
28
29
|
scheduled = Sidetiq.scheduled
|
29
30
|
|
@@ -38,7 +39,8 @@ class TestSidetiq < Sidetiq::TestCase
|
|
38
39
|
|
39
40
|
def test_scheduled_given_arguments
|
40
41
|
SimpleWorker.perform_at(Time.local(2011, 1, 1, 1))
|
41
|
-
|
42
|
+
hash = SimpleWorker.jobs.first
|
43
|
+
Sidekiq::Client.push_old(hash.merge("at" => hash["enqueued_at"]))
|
42
44
|
|
43
45
|
assert_equal 1, Sidetiq.scheduled(SimpleWorker).length
|
44
46
|
assert_equal 0, Sidetiq.scheduled(ScheduledWorker).length
|
@@ -49,10 +51,12 @@ class TestSidetiq < Sidetiq::TestCase
|
|
49
51
|
|
50
52
|
def test_scheduled_yields_each_job
|
51
53
|
SimpleWorker.perform_at(Time.local(2011, 1, 1, 1))
|
52
|
-
|
54
|
+
hash = SimpleWorker.jobs.first
|
55
|
+
Sidekiq::Client.push_old(hash.merge("at" => hash["enqueued_at"]))
|
53
56
|
|
54
57
|
ScheduledWorker.perform_at(Time.local(2011, 1, 1, 1))
|
55
|
-
|
58
|
+
hash = ScheduledWorker.jobs.first
|
59
|
+
Sidekiq::Client.push_old(hash.merge("at" => hash["enqueued_at"]))
|
56
60
|
|
57
61
|
jobs = []
|
58
62
|
Sidetiq.scheduled { |job| jobs << job }
|
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.3.
|
4
|
+
version: 0.3.2
|
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-
|
11
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.13.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.13.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ice_cube
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,8 +42,7 @@ description: Recurring jobs for Sidekiq
|
|
42
42
|
email:
|
43
43
|
- tob@tobiassvensson.co.uk
|
44
44
|
executables: []
|
45
|
-
extensions:
|
46
|
-
- ext/sidetiq_ext/extconf.rb
|
45
|
+
extensions: []
|
47
46
|
extra_rdoc_files: []
|
48
47
|
files:
|
49
48
|
- .gitignore
|
@@ -54,9 +53,6 @@ files:
|
|
54
53
|
- README.md
|
55
54
|
- Rakefile
|
56
55
|
- examples/simple.rb
|
57
|
-
- ext/sidetiq_ext/extconf.rb
|
58
|
-
- ext/sidetiq_ext/sidetiq_ext.c
|
59
|
-
- ext/sidetiq_ext/sidetiq_ext.h
|
60
56
|
- lib/sidetiq.rb
|
61
57
|
- lib/sidetiq/clock.rb
|
62
58
|
- lib/sidetiq/config.rb
|
@@ -77,7 +73,6 @@ files:
|
|
77
73
|
- test/helper.rb
|
78
74
|
- test/test_clock.rb
|
79
75
|
- test/test_config.rb
|
80
|
-
- test/test_errors.rb
|
81
76
|
- test/test_middleware.rb
|
82
77
|
- test/test_schedule.rb
|
83
78
|
- test/test_sidetiq.rb
|
@@ -86,7 +81,7 @@ files:
|
|
86
81
|
- test/test_worker.rb
|
87
82
|
homepage: http://github.com/tobiassvn/sidetiq
|
88
83
|
licenses:
|
89
|
-
-
|
84
|
+
- 3-clause BSD
|
90
85
|
metadata: {}
|
91
86
|
post_install_message:
|
92
87
|
rdoc_options: []
|
@@ -104,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
99
|
version: '0'
|
105
100
|
requirements: []
|
106
101
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.0.
|
102
|
+
rubygems_version: 2.0.3
|
108
103
|
signing_key:
|
109
104
|
specification_version: 4
|
110
105
|
summary: Recurring jobs for Sidekiq
|
@@ -118,7 +113,6 @@ test_files:
|
|
118
113
|
- test/helper.rb
|
119
114
|
- test/test_clock.rb
|
120
115
|
- test/test_config.rb
|
121
|
-
- test/test_errors.rb
|
122
116
|
- test/test_middleware.rb
|
123
117
|
- test/test_schedule.rb
|
124
118
|
- test/test_sidetiq.rb
|
data/ext/sidetiq_ext/extconf.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
#include <ruby.h>
|
2
|
-
#include <assert.h>
|
3
|
-
#include "sidetiq_ext.h"
|
4
|
-
|
5
|
-
#ifdef __APPLE__
|
6
|
-
#include <sys/time.h>
|
7
|
-
#include <sys/resource.h>
|
8
|
-
#include <mach/mach.h>
|
9
|
-
#include <mach/clock.h>
|
10
|
-
#include <mach/mach_time.h>
|
11
|
-
#include <errno.h>
|
12
|
-
#include <unistd.h>
|
13
|
-
#include <sched.h>
|
14
|
-
#else
|
15
|
-
#include <time.h>
|
16
|
-
#endif
|
17
|
-
|
18
|
-
VALUE msidetiq;
|
19
|
-
VALUE esidetiq_error;
|
20
|
-
VALUE csidetiq_clock;
|
21
|
-
|
22
|
-
#ifdef __APPLE__
|
23
|
-
static mach_timebase_info_data_t clock_gettime_inf;
|
24
|
-
|
25
|
-
typedef enum {
|
26
|
-
CLOCK_REALTIME,
|
27
|
-
CLOCK_MONOTONIC,
|
28
|
-
CLOCK_PROCESS_CPUTIME_ID,
|
29
|
-
CLOCK_THREAD_CPUTIME_ID
|
30
|
-
} clockid_t;
|
31
|
-
|
32
|
-
int clock_gettime(clockid_t clk_id, struct timespec *tp)
|
33
|
-
{
|
34
|
-
kern_return_t ret;
|
35
|
-
clock_serv_t clk;
|
36
|
-
clock_id_t clk_serv_id;
|
37
|
-
mach_timespec_t tm;
|
38
|
-
uint64_t start, end, delta, nano;
|
39
|
-
int retval = -1;
|
40
|
-
|
41
|
-
switch (clk_id) {
|
42
|
-
case CLOCK_REALTIME:
|
43
|
-
case CLOCK_MONOTONIC:
|
44
|
-
clk_serv_id = clk_id == CLOCK_REALTIME ? CALENDAR_CLOCK : SYSTEM_CLOCK;
|
45
|
-
if (KERN_SUCCESS == (ret = host_get_clock_service(mach_host_self(), clk_serv_id, &clk))) {
|
46
|
-
if (KERN_SUCCESS == (ret = clock_get_time(clk, &tm))) {
|
47
|
-
tp->tv_sec = tm.tv_sec;
|
48
|
-
tp->tv_nsec = tm.tv_nsec;
|
49
|
-
retval = 0;
|
50
|
-
}
|
51
|
-
}
|
52
|
-
if (KERN_SUCCESS != ret) {
|
53
|
-
errno = EINVAL;
|
54
|
-
retval = -1;
|
55
|
-
}
|
56
|
-
break;
|
57
|
-
case CLOCK_PROCESS_CPUTIME_ID:
|
58
|
-
case CLOCK_THREAD_CPUTIME_ID:
|
59
|
-
start = mach_absolute_time();
|
60
|
-
if (clk_id == CLOCK_PROCESS_CPUTIME_ID) {
|
61
|
-
getpid();
|
62
|
-
} else {
|
63
|
-
sched_yield();
|
64
|
-
}
|
65
|
-
end = mach_absolute_time();
|
66
|
-
delta = end - start;
|
67
|
-
if (0 == clock_gettime_inf.denom) {
|
68
|
-
mach_timebase_info(&clock_gettime_inf);
|
69
|
-
}
|
70
|
-
nano = delta * clock_gettime_inf.numer / clock_gettime_inf.denom;
|
71
|
-
tp->tv_sec = nano * 1e-9;
|
72
|
-
tp->tv_nsec = nano - (tp->tv_sec * 1e9);
|
73
|
-
retval = 0;
|
74
|
-
break;
|
75
|
-
default:
|
76
|
-
errno = EINVAL;
|
77
|
-
retval = -1;
|
78
|
-
}
|
79
|
-
return retval;
|
80
|
-
}
|
81
|
-
#endif
|
82
|
-
|
83
|
-
static VALUE sidetiq_gettime(VALUE self)
|
84
|
-
{
|
85
|
-
struct timespec time;
|
86
|
-
assert(clock_gettime(CLOCK_REALTIME, &time) == 0);
|
87
|
-
return rb_time_nano_new(time.tv_sec, time.tv_nsec);
|
88
|
-
}
|
89
|
-
|
90
|
-
void Init_sidetiq_ext()
|
91
|
-
{
|
92
|
-
msidetiq = rb_define_module("Sidetiq");
|
93
|
-
esidetiq_error = rb_define_class_under(msidetiq, "Error", rb_eStandardError);
|
94
|
-
csidetiq_clock = rb_define_class_under(msidetiq, "Clock", rb_cObject);
|
95
|
-
rb_define_private_method(csidetiq_clock, "clock_gettime", sidetiq_gettime, 0);
|
96
|
-
}
|
97
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#ifndef __SIDETIQ_EXT_H__
|
2
|
-
#define __SIDETIQ_EXT_H__
|
3
|
-
#include <ruby.h>
|
4
|
-
|
5
|
-
void Init_sidetiq_ext();
|
6
|
-
static VALUE sidetiq_gettime(VALUE self);
|
7
|
-
|
8
|
-
/* module Sidetiq */
|
9
|
-
extern VALUE msidetiq;
|
10
|
-
|
11
|
-
/* class Sidetiq::Error < StandardError */
|
12
|
-
extern VALUE esidetiq_error;
|
13
|
-
|
14
|
-
/* class Sidetiq::Clock */
|
15
|
-
extern VALUE csidetiq_clock;
|
16
|
-
|
17
|
-
#endif
|