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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b27e2e4e4be57df8dd1786682b5b60581c56ad16
4
- data.tar.gz: 9dff323de41c33ac48524b1ac8ab280790ec8b10
3
+ metadata.gz: dbb14d2cb9a6f7f0bffae45cd3ec7f00c8a2ad13
4
+ data.tar.gz: c44a7e5b308559bfb3c5d2bf10c108de1e9ff090
5
5
  SHA512:
6
- metadata.gz: 9f23da51d63a47876d1030350f76d8d34b6486234bdcf53f8b9c7753b9b046cf23d46a1bb9aa632406a0ab3d7faae3a531083578f89802564b39b299ffe53619
7
- data.tar.gz: c5db5145e7b68be1e43380874584465919e85f05597c550faf404349ea2f354753515b0533dc8d22fc013dc7778f8d4c7040746d9b444a9142cdea55813eb29b
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 [Sidetiq](https://github.com/tobiassvn/sidetiq),
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
@@ -35,6 +35,9 @@ task :web do
35
35
  config[:schedule] = sched
36
36
  end
37
37
 
38
+ class DoWork
39
+ end
40
+
38
41
  require 'sidekiq/web'
39
42
  require 'sidecloq/web'
40
43
 
data/lib/sidecloq.rb CHANGED
@@ -9,6 +9,7 @@ require 'sidecloq/schedule'
9
9
  require 'sidecloq/locker'
10
10
  require 'sidecloq/scheduler'
11
11
  require 'sidecloq/runner'
12
+ require 'sidecloq/job_enqueuer'
12
13
  require 'sidecloq/version'
13
14
 
14
15
  # Sideloq provides a lightweight recurring job scheduler for sidekiq
@@ -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
@@ -65,15 +65,10 @@ module Sidecloq
65
65
 
66
66
  # failed enqueuing should not b0rk stuff
67
67
  begin
68
- enqueue_job!(spec)
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
@@ -1,3 +1,3 @@
1
1
  module Sidecloq
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
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
- Sidekiq::Client.push(spec)
18
+ JobEnqueuer.new(spec).enqueue
19
19
  end
20
20
  # rubocop:enableLint/AssignmentInCondition
21
21
  redirect "#{root_path}recurring"
data/sidecloq.gemspec CHANGED
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rake', '~> 10.0'
29
29
  spec.add_development_dependency 'minitest'
30
30
  spec.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.2'
31
+ spec.add_development_dependency 'activejob'
31
32
  end
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.0
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: 2016-12-08 00:00:00.000000000 Z
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.4.5.1
187
+ rubygems_version: 2.6.8
173
188
  signing_key:
174
189
  specification_version: 4
175
190
  summary: Recurring jobs for Sidekiq