sidecloq 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile +11 -1
- data/README.md +3 -0
- data/lib/sidecloq.rb +6 -0
- data/lib/sidecloq/scheduler.rb +8 -14
- data/lib/sidecloq/version.rb +1 -1
- data/sidetoq.gemspec +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc79f44db3f6f94b4de477d87b170b6a8f0af0bf
|
4
|
+
data.tar.gz: c2cdd0e3641298003d3ae8f3b8072876b86f8316
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd2cf8af352b2c6c3a77dff7e00ca9d2124cd0145a242390d4c874bc7cefdd638a8cca97531a0a86042e4513aa4b9b19ec3d6225298e586ceac9f32845889f08
|
7
|
+
data.tar.gz: efacb0bce951f43c692e03b07536321baea03d448ed5d463a65f83aaa10b1697ba1acbfd04fd296d9c5c5017d4264ffb66991f05ddaa53af8da6f7cee9d3155d
|
data/.travis.yml
CHANGED
@@ -7,15 +7,21 @@ rvm:
|
|
7
7
|
- 2.0.0
|
8
8
|
- 2.1.8
|
9
9
|
- 2.2.4
|
10
|
+
- 2.3.0
|
10
11
|
- ruby-head
|
11
12
|
- jruby-9.0.4.0
|
12
13
|
- jruby-head
|
13
14
|
- rbx-2.6
|
14
15
|
- rbx-2.7
|
16
|
+
env:
|
17
|
+
- "sidekiq=master"
|
18
|
+
- "sidekiq=stable"
|
19
|
+
- "sidekiq=3.5.3"
|
15
20
|
matrix:
|
16
21
|
allow_failures:
|
17
22
|
- rvm: ruby-head
|
18
23
|
- rvm: jruby-head
|
24
|
+
- env: "sidekiq=master"
|
19
25
|
addons:
|
20
26
|
code_climate:
|
21
27
|
repo_token: dee2fdcb3562533038a22e862c0fc91a6f1fa38730cd2b77177655e5b9507c83
|
data/Gemfile
CHANGED
@@ -2,9 +2,19 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
platforms :mri do
|
5
|
+
platforms :mri, :rbx do
|
6
6
|
gem 'pry'
|
7
7
|
gem 'minitest-utils'
|
8
8
|
end
|
9
9
|
|
10
|
+
# https://github.com/sinatra/sinatra/blob/master/Gemfile
|
11
|
+
sidekiq_dep =
|
12
|
+
case ENV['sidekiq']
|
13
|
+
when 'stable', nil then nil
|
14
|
+
when /(\d+\.)+\d+/ then "~> " + ENV['sidekiq'].sub("sidekiq-", '')
|
15
|
+
else {github: 'mperham/sidekiq', branch: ENV['sidekiq']}
|
16
|
+
end
|
17
|
+
|
18
|
+
gem 'sidekiq', sidekiq_dep
|
19
|
+
|
10
20
|
gem 'codeclimate-test-reporter', group: :test, require: false
|
data/README.md
CHANGED
data/lib/sidecloq.rb
CHANGED
@@ -44,8 +44,13 @@ module Sidecloq
|
|
44
44
|
@runner.run
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.running?
|
48
|
+
!!@runner
|
49
|
+
end
|
50
|
+
|
47
51
|
def self.shutdown
|
48
52
|
@runner.stop(options[:timeout] || 10) if @runner
|
53
|
+
@runner = nil
|
49
54
|
end
|
50
55
|
|
51
56
|
def self.extract_schedule
|
@@ -56,6 +61,7 @@ module Sidecloq
|
|
56
61
|
|
57
62
|
# try for a file
|
58
63
|
options[:schedule_file] ||= 'config/sidecloq.yml'
|
64
|
+
|
59
65
|
if File.exist?(options[:schedule_file])
|
60
66
|
return Schedule.from_yaml(options[:schedule_file])
|
61
67
|
elsif defined?(Rails)
|
data/lib/sidecloq/scheduler.rb
CHANGED
@@ -6,6 +6,7 @@ module Sidecloq
|
|
6
6
|
def initialize(schedule, options = {})
|
7
7
|
@schedule = schedule
|
8
8
|
@options = options
|
9
|
+
@loaded = Concurrent::Event.new
|
9
10
|
end
|
10
11
|
|
11
12
|
# run queues jobs per their schedules, blocking forever
|
@@ -14,30 +15,22 @@ module Sidecloq
|
|
14
15
|
sync_with_redis
|
15
16
|
logger.info('Starting scheduler')
|
16
17
|
load_schedule_into_rufus
|
17
|
-
logger.debug('Joining rufus thread')
|
18
18
|
rufus.join
|
19
|
-
logger.debug('Scheduler run ended')
|
20
19
|
end
|
21
20
|
|
22
21
|
def stop(timeout = nil)
|
23
22
|
logger.info("Stopping scheduler (timeout: #{timeout})")
|
24
|
-
|
25
|
-
|
26
|
-
rufus.shutdown(:kill) if rufus.up?
|
27
|
-
end
|
28
|
-
Thread.new do
|
29
|
-
rufus.shutdown(:wait)
|
30
|
-
t.cancel
|
31
|
-
end
|
32
|
-
else
|
33
|
-
rufus.shutdown(:wait)
|
34
|
-
end
|
35
|
-
rufus.join
|
23
|
+
rufus.shutdown(:kill)
|
24
|
+
rufus.thread.join(timeout)
|
36
25
|
logger.info('Stopped scheduler')
|
37
26
|
end
|
38
27
|
|
39
28
|
private unless $TESTING
|
40
29
|
|
30
|
+
def wait_for_loaded
|
31
|
+
@loaded.wait
|
32
|
+
end
|
33
|
+
|
41
34
|
def rufus
|
42
35
|
@rufus ||= Rufus::Scheduler.new
|
43
36
|
end
|
@@ -51,6 +44,7 @@ module Sidecloq
|
|
51
44
|
@schedule.job_specs.each do |name, spec|
|
52
45
|
load_into_rufus(name, spec)
|
53
46
|
end
|
47
|
+
@loaded.set
|
54
48
|
end
|
55
49
|
|
56
50
|
def load_into_rufus(name, spec)
|
data/lib/sidecloq/version.rb
CHANGED
data/sidetoq.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.add_dependency 'sidekiq', '
|
22
|
+
spec.add_dependency 'sidekiq', '>= 3.5.3', '< 5'
|
23
23
|
spec.add_dependency 'redlock', '~> 0.1.2'
|
24
24
|
# mimics some dev dependencies of sidekiq:
|
25
25
|
spec.add_dependency 'concurrent-ruby'
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidecloq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Robinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.5.3
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: '5'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.5.3
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: '5'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: redlock
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|