sidecloq 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/README.md +1 -2
- data/Rakefile +3 -0
- data/lib/sidecloq.rb +1 -0
- data/lib/sidecloq/job_enqueuer.rb +34 -0
- data/lib/sidecloq/scheduler.rb +1 -6
- data/lib/sidecloq/version.rb +1 -1
- data/lib/sidecloq/web.rb +1 -1
- data/sidecloq.gemspec +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbb14d2cb9a6f7f0bffae45cd3ec7f00c8a2ad13
|
4
|
+
data.tar.gz: c44a7e5b308559bfb3c5d2bf10c108de1e9ff090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f613f8c63b1d6e3bd87682e740a1e56fdf2796be6b5488967cda62fbd5f9ce417382ca42ee3ae7ac3b3a3975636b13a03c518d80eee59c47e20ac245565cb2ea
|
7
|
+
data.tar.gz: 69f054480ede7d3318804bbff1d9b0b59c46b40210fa2cac10aea2691fb8d4912027537f48599c0803b4015f75b716830adbea0af39878efc4d77d4e2b0a9f0e
|
data/Gemfile
CHANGED
@@ -17,9 +17,11 @@ sidekiq_dep =
|
|
17
17
|
|
18
18
|
gem 'sidekiq', sidekiq_dep
|
19
19
|
|
20
|
-
# rack >= 2.0 requires ruby >= 2.2.2
|
21
20
|
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.2.2")
|
21
|
+
# rack >= 2.0 requires ruby >= 2.2.2
|
22
22
|
gem 'rack', '< 2.0'
|
23
|
+
# activejob >= 5 requires ruby >= 2.2.2
|
24
|
+
gem 'activejob', '< 5'
|
23
25
|
end
|
24
26
|
|
25
27
|
group :test do
|
data/README.md
CHANGED
@@ -14,8 +14,7 @@ Recurring / Periodic / Scheduled / Cron job extension for
|
|
14
14
|
## Why
|
15
15
|
|
16
16
|
There are several options for running periodic tasks with Sidekiq,
|
17
|
-
including [
|
18
|
-
[sidekiq-scheduler](https://github.com/Moove-it/sidekiq-scheduler),
|
17
|
+
including [sidekiq-scheduler](https://github.com/Moove-it/sidekiq-scheduler),
|
19
18
|
[sidekiq-cron](https://github.com/ondrejbartas/sidekiq-cron), as well as
|
20
19
|
[Sidekiq Pro](http://sidekiq.org/products/pro). Each tackles the
|
21
20
|
problem slightly differently. Sidecloq is inspired by various facets
|
data/Rakefile
CHANGED
data/lib/sidecloq.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Sidecloq
|
2
|
+
class JobEnqueuer
|
3
|
+
attr_reader :spec, :klass
|
4
|
+
|
5
|
+
def initialize(spec)
|
6
|
+
@spec = spec
|
7
|
+
@klass = spec['class'].constantize
|
8
|
+
end
|
9
|
+
|
10
|
+
def enqueue
|
11
|
+
if active_job_class?
|
12
|
+
initialize_active_job_class.enqueue(queue: spec['queue'])
|
13
|
+
else
|
14
|
+
Sidekiq::Client.push(spec)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private unless $TESTING
|
19
|
+
|
20
|
+
def active_job_class?
|
21
|
+
defined?(ActiveJob::Base) && klass < ActiveJob::Base
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize_active_job_class
|
25
|
+
args = spec['args']
|
26
|
+
|
27
|
+
if args.is_a?(Array)
|
28
|
+
klass.new(*args)
|
29
|
+
else
|
30
|
+
klass.new(args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/sidecloq/scheduler.rb
CHANGED
@@ -65,15 +65,10 @@ module Sidecloq
|
|
65
65
|
|
66
66
|
# failed enqueuing should not b0rk stuff
|
67
67
|
begin
|
68
|
-
|
68
|
+
JobEnqueuer.new(spec).enqueue
|
69
69
|
rescue => e
|
70
70
|
logger.info "error enqueuing #{name} - #{e.class.name}: #{e.message}"
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
74
|
-
# can raise exceptions, but shouldn't
|
75
|
-
def enqueue_job!(spec)
|
76
|
-
Sidekiq::Client.push(spec)
|
77
|
-
end
|
78
73
|
end
|
79
74
|
end
|
data/lib/sidecloq/version.rb
CHANGED
data/lib/sidecloq/web.rb
CHANGED
@@ -15,7 +15,7 @@ module Sidecloq
|
|
15
15
|
|
16
16
|
# rubocop:disable Lint/AssignmentInCondition
|
17
17
|
if spec = Sidecloq::Schedule.from_redis.job_specs[job_name]
|
18
|
-
|
18
|
+
JobEnqueuer.new(spec).enqueue
|
19
19
|
end
|
20
20
|
# rubocop:enableLint/AssignmentInCondition
|
21
21
|
redirect "#{root_path}recurring"
|
data/sidecloq.gemspec
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Robinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -126,6 +126,20 @@ dependencies:
|
|
126
126
|
- - ">="
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: 1.5.2
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: activejob
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
129
143
|
description: Recurring jobs for Sidekiq
|
130
144
|
email:
|
131
145
|
- robinson.matty@gmail.com
|
@@ -140,6 +154,7 @@ files:
|
|
140
154
|
- README.md
|
141
155
|
- Rakefile
|
142
156
|
- lib/sidecloq.rb
|
157
|
+
- lib/sidecloq/job_enqueuer.rb
|
143
158
|
- lib/sidecloq/locker.rb
|
144
159
|
- lib/sidecloq/runner.rb
|
145
160
|
- lib/sidecloq/schedule.rb
|
@@ -169,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
184
|
version: '0'
|
170
185
|
requirements: []
|
171
186
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.6.8
|
173
188
|
signing_key:
|
174
189
|
specification_version: 4
|
175
190
|
summary: Recurring jobs for Sidekiq
|