sidecloq 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -14
- data/Gemfile +0 -1
- data/README.md +1 -1
- data/lib/sidecloq/locker.rb +29 -7
- data/lib/sidecloq/runner.rb +3 -5
- data/lib/sidecloq/scheduler.rb +5 -0
- data/lib/sidecloq/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 391595a334f67b866a31fdee2e0c0c1c7d3c2de6e9009825c7e473e1a89171df
|
4
|
+
data.tar.gz: 44991afad3f26e97d70b22a8861641ad9b1619ec83c51c63c62ef8ff2a1ae723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f7df231b254bf0915229a4de09a3df0fdc9d4e90cc8e8855c2f7b157a300c3636fe10669413066fe13ed86d5194ba6b416a74c628a31a9da70ace3e575ff7ad
|
7
|
+
data.tar.gz: 05c6c316b6f4258b46385d3d950915e80f02a21d2dcd57549b35d11d696bb75579488b5873530044fb4bb8e65835526095fdf908f79c40e6022826ed1b2be49f
|
data/.travis.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
dist: bionic
|
1
2
|
language: ruby
|
2
3
|
sudo: false
|
3
4
|
cache: bundler
|
@@ -11,14 +12,9 @@ rvm:
|
|
11
12
|
- 2.4.5
|
12
13
|
- 2.5.3
|
13
14
|
- 2.6.1
|
14
|
-
- ruby-head
|
15
|
-
- jruby-9.0.4.0
|
16
15
|
- jruby-9.1.17.0
|
17
|
-
- jruby-
|
18
|
-
- rbx-2.11
|
19
|
-
- rbx-3.84
|
16
|
+
- jruby-9.2.5.0
|
20
17
|
env:
|
21
|
-
- "sidekiq=stable"
|
22
18
|
- "sidekiq=3.5.4"
|
23
19
|
- "sidekiq=4.2.10"
|
24
20
|
- "sidekiq=5.1.3"
|
@@ -26,28 +22,21 @@ env:
|
|
26
22
|
- "sidekiq=master"
|
27
23
|
matrix:
|
28
24
|
allow_failures:
|
29
|
-
- rvm: ruby-head
|
30
|
-
- rvm: jruby-head
|
31
|
-
- rvm: rbx-2.11
|
32
|
-
- rvm: rbx-3.84
|
33
25
|
- env: "sidekiq=master"
|
34
26
|
exclude:
|
35
27
|
# sidekiq 5 does not support < ruby 2.2.2
|
36
28
|
- rvm: 2.0.0
|
37
29
|
env: sidekiq=master
|
38
|
-
- rvm: 2.0.0
|
39
|
-
env: sidekiq=stable
|
40
30
|
- rvm: 2.0.0
|
41
31
|
env: sidekiq=5.1.3
|
42
32
|
- rvm: 2.0.0
|
43
33
|
env: sidekiq=5.2.5
|
44
34
|
- rvm: 2.1.10
|
45
35
|
env: sidekiq=master
|
46
|
-
- rvm: 2.1.10
|
47
|
-
env: sidekiq=stable
|
48
36
|
- rvm: 2.1.10
|
49
37
|
env: sidekiq=5.1.3
|
50
38
|
- rvm: 2.1.10
|
51
39
|
env: sidekiq=5.2.5
|
40
|
+
fast_finish: true
|
52
41
|
after_success:
|
53
42
|
- bundle exec codeclimate-test-reporter
|
data/Gemfile
CHANGED
@@ -10,7 +10,6 @@ end
|
|
10
10
|
# https://github.com/sinatra/sinatra/blob/master/Gemfile
|
11
11
|
sidekiq_dep =
|
12
12
|
case ENV['sidekiq']
|
13
|
-
when 'stable', nil then nil
|
14
13
|
when /(\d+\.)+\d+/ then "~> " + ENV['sidekiq'].sub("sidekiq-", '')
|
15
14
|
else {github: 'mperham/sidekiq', branch: ENV['sidekiq']}
|
16
15
|
end
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Add this line to your application's Gemfile:
|
|
44
44
|
gem 'sidecloq'
|
45
45
|
```
|
46
46
|
|
47
|
-
Tested on MRI > 2
|
47
|
+
Tested on MRI > 2 and JRuby 9k. Basically, if you can run
|
48
48
|
Sidekiq, you can run Sidecloq. Note that Sidekiq >= 5 does not support
|
49
49
|
MRI ruby < 2.2.2.
|
50
50
|
|
data/lib/sidecloq/locker.rb
CHANGED
@@ -13,28 +13,47 @@ module Sidecloq
|
|
13
13
|
@check_interval = options[:check_interval] || 15
|
14
14
|
@lock_manager = Redlock::Client.new([@redis])
|
15
15
|
@obtained_lock = Concurrent::Event.new
|
16
|
+
@check_task = nil
|
16
17
|
@lock = nil
|
18
|
+
@stopping = false
|
19
|
+
@in_with_lock = false
|
17
20
|
end
|
18
21
|
|
19
22
|
# blocks until lock is obtained, then yields
|
20
23
|
def with_lock
|
24
|
+
@in_with_lock = true
|
25
|
+
|
21
26
|
start
|
22
27
|
@obtained_lock.wait
|
23
|
-
|
28
|
+
|
29
|
+
yield if locked?
|
30
|
+
|
24
31
|
stop
|
32
|
+
@stopping = false
|
33
|
+
|
34
|
+
@in_with_lock = false
|
25
35
|
end
|
26
36
|
|
27
37
|
def stop(timeout = nil)
|
28
|
-
return
|
38
|
+
return if @stopping
|
39
|
+
|
40
|
+
@stopping = true
|
29
41
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
42
|
+
if @check_task
|
43
|
+
logger.debug('Stopping locker check task')
|
44
|
+
@check_task.shutdown
|
45
|
+
@check_task.wait_for_termination(timeout)
|
46
|
+
logger.debug('Stopped locker check task')
|
47
|
+
end
|
48
|
+
|
49
|
+
# release the lock in case someone is blocked on with_lock
|
50
|
+
@obtained_lock.set
|
51
|
+
|
52
|
+
@stopping = false unless @in_with_lock
|
34
53
|
end
|
35
54
|
|
36
55
|
def locked?
|
37
|
-
@obtained_lock.set?
|
56
|
+
!@stopping && @lock && @obtained_lock.set?
|
38
57
|
end
|
39
58
|
|
40
59
|
private unless $TESTING
|
@@ -48,6 +67,9 @@ module Sidecloq
|
|
48
67
|
try_to_get_or_refresh_lock
|
49
68
|
end
|
50
69
|
@check_task.execute
|
70
|
+
|
71
|
+
# return the check task, to help with tests
|
72
|
+
@check_task
|
51
73
|
end
|
52
74
|
|
53
75
|
def try_to_get_or_refresh_lock
|
data/lib/sidecloq/runner.rb
CHANGED
@@ -25,11 +25,9 @@ module Sidecloq
|
|
25
25
|
|
26
26
|
def stop(timeout = nil)
|
27
27
|
logger.debug('Stopping runner')
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
@thread.join if @thread
|
28
|
+
@scheduler.stop(timeout)
|
29
|
+
@locker.stop(timeout)
|
30
|
+
@thread.join(timeout) if @thread
|
33
31
|
logger.debug('Stopped runner')
|
34
32
|
end
|
35
33
|
|
data/lib/sidecloq/scheduler.rb
CHANGED
@@ -7,10 +7,12 @@ module Sidecloq
|
|
7
7
|
@schedule = schedule
|
8
8
|
@options = options
|
9
9
|
@loaded = Concurrent::Event.new
|
10
|
+
@running = false
|
10
11
|
end
|
11
12
|
|
12
13
|
# run queues jobs per their schedules, blocking forever
|
13
14
|
def run
|
15
|
+
@running = true
|
14
16
|
logger.info('Loading schedules into redis')
|
15
17
|
sync_with_redis
|
16
18
|
logger.info('Starting scheduler')
|
@@ -19,9 +21,12 @@ module Sidecloq
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def stop(timeout = nil)
|
24
|
+
return unless @running
|
22
25
|
logger.info("Stopping scheduler (timeout: #{timeout})")
|
23
26
|
rufus.shutdown(:kill)
|
24
27
|
rufus.thread.join(timeout)
|
28
|
+
@running = false
|
29
|
+
|
25
30
|
logger.info('Stopped scheduler')
|
26
31
|
end
|
27
32
|
|
data/lib/sidecloq/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidecloq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Robinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|