rekiq 1.1.0 → 1.2.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: bf6b35a349d92b73f219e0d576bc246eb57447f5
4
- data.tar.gz: b26a1901ec408176fedc25be6a51f66d5849bd59
3
+ metadata.gz: 076c615c498fc220128027310ad06d8bb2bb994f
4
+ data.tar.gz: 7e5af8a28c1c9091a5fd525b14618f207bf4ac1a
5
5
  SHA512:
6
- metadata.gz: d9a7e979b1f492540c788747b3dd7854ed3f27b1567bec4c15d568c65fd7df6715a7745c77d335bab19a8438e27b6f49ce8cff9596a891c87eedb357b05c3cd0
7
- data.tar.gz: 491e3f5219bc3e0bae2ad6e725a3af8ad8844a0d324059d7cc7e817515f01617e861cac634a9cf7b472d334d6f43239b7fe74164a9dd0de850ef0ae6e8f1a036
6
+ metadata.gz: f98477c020f73f06565d30c9056836ea99aa6a667f15d1ecc7744f772ffd9930e8cb419537063bf94c74afe0e969eec1cd0eee7afaa9c47f0a31532c441e9990
7
+ data.tar.gz: 0fc94f9ea4c19c537d2b9187e9232a7b3cb5c8fbf51edddd8a9d447e06a5c3535949e7c96f34a5e95845691c39f00eff2389984b2c6a1dd79f573c25c7ede296
data/.gitignore CHANGED
@@ -21,3 +21,5 @@ tmp
21
21
  *.a
22
22
  mkmf.log
23
23
  example/tmp
24
+
25
+ dump.rdb
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.1
1
+ ruby-2.2.0
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.2.0
3
4
  - 2.1.1
4
5
  - 2.0.0
5
- script: CODECLIMATE_REPO_TOKEN=13221c16cb92c5dc8312b2f2f9f4960271e67845ba5e2852dbba3d786ccf2c81 bundle exec rspec
6
+ script: CODECLIMATE_REPO_TOKEN=13221c16cb92c5dc8312b2f2f9f4960271e67845ba5e2852dbba3d786ccf2c81 bundle exec rspec
7
+ before_install: gem install bundler
data/README.md CHANGED
@@ -11,10 +11,10 @@
11
11
 
12
12
  Rekiq extends Sidekiq and adds functionality to schedule recurring workers.
13
13
 
14
- Sidekiq is an amazing gem that allows us to execute work asynchronous, or
15
- even schedule that work to be run at a given time. Now, wouldn't it be
16
- nice if it also allowed us to schedule a worker to do recurring work? That's
17
- what rekiq purposes to do.
14
+ Sidekiq is an amazing gem that allows us to execute work asynchronously, or
15
+ even schedule work to be run at a given time. Now, wouldn't it be nice
16
+ if it also allowed us to schedule a worker to do recurring work? That's
17
+ the purpose of rekiq.
18
18
 
19
19
  For example, rekiq allows you to schedule a worker to repeat the same
20
20
  work every friday at 23:00.
@@ -23,9 +23,9 @@ work every friday at 23:00.
23
23
 
24
24
  Tested with:
25
25
 
26
- * ruby 2.1.1, 2.0.0
26
+ * ruby 2.2.0, 2.1.1, 2.0.0
27
27
 
28
- * sidekiq 3.2.2
28
+ * sidekiq 3.3.3
29
29
 
30
30
  ## Installation
31
31
 
@@ -15,22 +15,22 @@ module Rekiq
15
15
  def initialize
16
16
  # indicates if next work is scheduled after or before the worker completes
17
17
  # this is relevant when we want to guarantee that workers do not run in paralel
18
- # default false
18
+ # type bool, default false
19
19
  @schedule_post_work = false
20
20
 
21
21
  # indicates a shift, in seconds, to apply to event time returned from schedule
22
22
  # to calculate the work_time
23
- # default 0
23
+ # type int, default 0
24
24
  @work_time_shift = 0
25
25
 
26
26
  # indicates the tolerance, in seconds, for work_time relative to current time
27
- # default 0 and must be greater than or equal to 0
27
+ # type int (value greater than or equal to 0), default 0
28
28
  @work_time_tolerance = 0
29
29
 
30
30
  # indicates if expired work_times are to be scheduled
31
31
  # a work_time is considered expired when it's before current time minus
32
32
  # work_time_tolerance
33
- # default false
33
+ # type bool, default false
34
34
  @schedule_expired = false
35
35
  end
36
36
  end
@@ -17,14 +17,13 @@ module Rekiq
17
17
 
18
18
  class << self
19
19
  def from_hash(hash)
20
- new \
21
- 'schedule' => Marshal.load(hash['s'].encode('ISO-8859-1')),
22
- 'cancel_args' => hash['ca'],
23
- 'addon' => hash['ao'],
24
- 'schedule_post_work' => hash['pw'],
25
- 'work_time_shift' => hash['ws'],
26
- 'work_time_tolerance' => hash['wt'],
27
- 'schedule_expired' => hash['se']
20
+ new 'schedule' => Marshal.load(hash['s'].encode('ISO-8859-1')),
21
+ 'cancel_args' => hash['ca'],
22
+ 'addon' => hash['ao'],
23
+ 'schedule_post_work' => hash['pw'],
24
+ 'work_time_shift' => hash['ws'],
25
+ 'work_time_tolerance' => hash['wt'],
26
+ 'schedule_expired' => hash['se']
28
27
  end
29
28
  end
30
29
 
@@ -40,7 +40,7 @@ module Rekiq
40
40
  protected
41
41
 
42
42
  def set_rekiq_worker_attributes
43
- @worker.scheduled_work_time = Time.at(@msg['rq:at'].to_f).utc
43
+ @worker.scheduled_work_time = Time.at(@msg['rq:at'].to_f)
44
44
  @worker.estimated_next_work_time =
45
45
  @contract.next_work_time(@worker.scheduled_work_time)
46
46
  end
@@ -49,7 +49,7 @@ module Rekiq
49
49
  @worker.cancel_rekiq_worker?(*@contract.cancel_args)
50
50
  end
51
51
 
52
- def reschedule()
52
+ def reschedule
53
53
  jid, work_time =
54
54
  Rekiq::Scheduler
55
55
  .new(@worker_name, @queue, @msg['args'], @contract)
@@ -24,17 +24,14 @@ module Rekiq
24
24
  end
25
25
 
26
26
  def push_to_redis
27
- client_args = {
28
- 'at' => @work_time.to_f,
29
- 'queue' => @queue,
30
- 'class' => @worker_name,
31
- 'args' => @args,
32
- 'rq:ctr' => @contract.to_hash,
33
- 'rq:sdl' => nil,
34
- 'rq:at' => @work_time.to_f # this needs to be here because the key 'at' is removed by sidekiq
35
- }
36
-
37
- Sidekiq::Client.push(client_args)
27
+ Sidekiq::Client
28
+ .push 'at' => @work_time.to_f,
29
+ 'queue' => @queue,
30
+ 'class' => @worker_name,
31
+ 'args' => @args,
32
+ 'rq:ctr' => @contract.to_hash,
33
+ 'rq:sdl' => nil,
34
+ 'rq:at' => @work_time.to_f # this needs to be here because the key 'at' is removed by sidekiq
38
35
  end
39
36
  end
40
37
  end
data/lib/rekiq/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rekiq
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/rekiq/worker.rb CHANGED
@@ -47,6 +47,7 @@ module Rekiq
47
47
 
48
48
  jid
49
49
  end
50
+ alias_method :perform_schedule, :perform_recurringly
50
51
 
51
52
  protected
52
53
 
data/rekiq.gemspec CHANGED
@@ -21,13 +21,13 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = '>= 2.0.0'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.6'
25
- spec.add_development_dependency 'rspec', '~> 3.0'
24
+ spec.add_development_dependency 'bundler', '~> 1.9'
25
+ spec.add_development_dependency 'rspec', '~> 3.2'
26
26
  spec.add_development_dependency 'simplecov', '~> 0.9'
27
27
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
28
- spec.add_development_dependency 'factory_girl', '~> 4.4'
28
+ spec.add_development_dependency 'factory_girl', '~> 4.5'
29
29
  spec.add_development_dependency 'ice_cube', '~> 0.12'
30
- spec.add_development_dependency 'sidekiq', '~> 3.2'
30
+ spec.add_development_dependency 'sidekiq', '~> 3.3'
31
31
 
32
- # spec.add_development_dependency 'jazz_hands', '~> 0.5'
32
+ spec.add_development_dependency 'pry'
33
33
  end
@@ -25,19 +25,44 @@ describe Rekiq::Worker do
25
25
  ExampleWorker.respond_to? :perform_recurringly
26
26
  end
27
27
 
28
- describe '.perform_recurringly' do
29
- context 'for schedule that does not return next occurrence' do
28
+ it 'responds to perform_schedule' do
29
+ ExampleWorker.respond_to? :perform_schedule
30
+ end
31
+
32
+ describe '.perform_recurringly (alias .perform_schedule)' do
33
+ context 'for schedule that is set to one hour ago' do
30
34
  let(:schedule) { IceCube::Schedule.new(Time.now - 3600) }
31
- before do
32
- @jid = ExampleWorker.perform_recurringly(schedule)
33
- end
34
35
 
35
- it 'returns nil' do
36
- expect(@jid).to eq(nil)
36
+ context 'with default config' do
37
+ before do
38
+ @jid = ExampleWorker.perform_recurringly(schedule)
39
+ end
40
+
41
+ it 'returns nil' do
42
+ expect(@jid).to eq(nil)
43
+ end
44
+
45
+ it 'does not schedule worker' do
46
+ expect(ExampleWorker.jobs.count).to eq(0)
47
+ end
37
48
  end
38
49
 
39
- it 'does not schedule worker' do
40
- expect(ExampleWorker.jobs.count).to eq(0)
50
+ context 'configured to start at two hours ago and ' \
51
+ 'set to schedule expired work' do
52
+ before do
53
+ @jid = ExampleWorker.perform_recurringly(schedule) do |config|
54
+ config.starting_at = Time.now - 7200
55
+ config.schedule_expired = true
56
+ end
57
+ end
58
+
59
+ it 'returns a jid' do
60
+ expect(@jid).not_to eq(nil)
61
+ end
62
+
63
+ it 'does not schedule worker' do
64
+ expect(ExampleWorker.jobs.count).to eq(1)
65
+ end
41
66
  end
42
67
  end
43
68
 
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,7 @@ require 'factory_girl'
12
12
  require 'sidekiq'
13
13
  require 'sidekiq/testing'
14
14
  require 'rekiq'
15
+ require 'pry'
15
16
 
16
17
  # configure sidekiq for testing
17
18
  Sidekiq::Testing.fake!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - junhanamaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-05 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.9'
20
20
  type: :development
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: '1.6'
26
+ version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '3.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '4.4'
75
+ version: '4.5'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '4.4'
82
+ version: '4.5'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ice_cube
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.2'
103
+ version: '3.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.2'
110
+ version: '3.3'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: |-
112
126
  Rekiq extends Sidekiq to allow the scheduling of
113
127
  recurring workers
@@ -166,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
180
  version: '0'
167
181
  requirements: []
168
182
  rubyforge_project:
169
- rubygems_version: 2.2.2
183
+ rubygems_version: 2.4.5
170
184
  signing_key:
171
185
  specification_version: 4
172
186
  summary: Recurring worker extension for Sidekiq
@@ -179,4 +193,3 @@ test_files:
179
193
  - spec/rekiq/scheduler_spec.rb
180
194
  - spec/rekiq/worker_spec.rb
181
195
  - spec/spec_helper.rb
182
- has_rdoc: