sidetiq 0.3.1 → 0.3.2

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: 6d833d80ba92d8c2ab671eaf83018b756a6a610f
4
- data.tar.gz: db7174cfce2e6e2f1f2f915973d20aae2d8b0b29
3
+ metadata.gz: fe87e48535b00a33d15395b564b62fce3a4ed68d
4
+ data.tar.gz: 1cb3287fdd6312b1792c11d46561b495cba27114
5
5
  SHA512:
6
- metadata.gz: 81e03ae40d22adf557accb0bb171737889b4a929b47632c58051a7285d016de6edb8cd0ae7771c0e6ba245b17a73e937c2189d2c37234844a6b64ab74eb87be4
7
- data.tar.gz: e52280dc91517a904e3746d63ed25199eb0e27b02bf8ae3301bb599b03823d1454286b7c0969e317f459f9a79a829bf5b4faecd051e54c6dd021d9c4e08a50e7
6
+ metadata.gz: 040024621688bf956b27cee9f85235d348886e09d315cd07ada3c85faa991f02068a3e37b705307aac499aef0b7dc0f6cbaef498271149dab602a50e04a2a9e5
7
+ data.tar.gz: 6de537a1815d7cf3a1e3830efd36883b84a79ff034f54012d7c63ca809eddac5ec7e8315c0b291889cade9b63e4d73aa604606553c10116045c60cc79e9f65f2
data/.travis.yml CHANGED
@@ -1,14 +1,10 @@
1
1
  language: ruby
2
- before_script:
3
- - bundle exec rake compile
4
2
  rvm:
5
3
  - 1.9.2
6
4
  - 1.9.3
7
5
  - 2.0.0
8
- - ruby-head
9
6
  - jruby-19mode
10
7
  - rbx-19mode
11
8
  matrix:
12
9
  allow_failures:
13
10
  - rvm: 1.9.2
14
- - rvm: jruby-19mode
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
@@ -2,7 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
4
  gem 'rake'
5
- gem 'rake-compiler'
6
5
  gem 'sinatra', require: false
7
6
  gem 'slim', require: false
8
7
  end
data/LICENSE CHANGED
@@ -1,20 +1,24 @@
1
- Copyright (C) 2012 by Tobias Svensson <tobias@musicglue.com>
1
+ Copyright (c) 2012-2013, Tobias Svensson <tobias@musicglue.com>
2
+ All rights reserved.
2
3
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
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 MIT License. See LICENSE for further details.
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
@@ -1,8 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
- require 'rake/extensiontask'
4
-
5
- Rake::ExtensionTask.new('sidetiq_ext')
6
3
 
7
4
  Rake::TestTask.new do |t|
8
5
  t.pattern = 'test/**/test_*.rb'
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 ? clock_gettime.utc : clock_gettime
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
- redis.pexpire(lock, Sidetiq.config.lock_expire)
160
- yield redis
161
- redis.del(lock)
162
-
163
- Sidetiq.logger.debug "Sidetiq::Clock unlock #{lock}"
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
@@ -8,7 +8,7 @@ module Sidetiq
8
8
  MINOR = 3
9
9
 
10
10
  # Public: Sidetiq patch level.
11
- PATCH = 1
11
+ PATCH = 2
12
12
 
13
13
  # Public: String representation of the current Sidetiq version.
14
14
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
data/lib/sidetiq.rb CHANGED
@@ -7,9 +7,6 @@ require 'singleton'
7
7
  require 'ice_cube'
8
8
  require 'sidekiq'
9
9
 
10
- # c extensions
11
- require 'sidetiq_ext'
12
-
13
10
  # internal
14
11
  require 'sidetiq/config'
15
12
  require 'sidetiq/clock'
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 = "MIT"
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 = ['ext/sidetiq_ext/extconf.rb']
20
+ gem.extensions = []
21
21
 
22
- gem.add_dependency 'sidekiq', '~> 2.12.0'
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
- Sidekiq::Client.push_old(SimpleWorker.jobs.first)
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
- Sidekiq::Client.push_old(SimpleWorker.jobs.first)
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
- Sidekiq::Client.push_old(SimpleWorker.jobs.first)
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
- Sidekiq::Client.push_old(ScheduledWorker.jobs.first)
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.1
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-06-20 00:00:00.000000000 Z
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.12.0
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.12.0
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
- - MIT
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.2
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
@@ -1,4 +0,0 @@
1
- require 'rbconfig'
2
- require 'mkmf'
3
- create_makefile('sidetiq_ext')
4
-
@@ -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
data/test/test_errors.rb DELETED
@@ -1,7 +0,0 @@
1
- require_relative 'helper'
2
-
3
- class TestErrors < Sidetiq::TestCase
4
- def test_error_superclass
5
- assert_equal StandardError, Sidetiq::Error.superclass
6
- end
7
- end