sidekiq_publisher 1.8.0 → 2.1.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
  SHA256:
3
- metadata.gz: b87dcb63524894c48e9a75cb8ed5773fddaa897e599fbb0f9c18c2fc06d7c30e
4
- data.tar.gz: f8656103322b18569ee5f5ca131e1a40348d3f7d686eb3d3f22b9481a816d89a
3
+ metadata.gz: aa63cc2e02febd7a4fe0da8a1deba89df521cf9df46d453626ee80c45cb441c1
4
+ data.tar.gz: 8c4ba92a29040892080f1b0248dfec8a6f1193063f054c48d6736e3fc15a9e40
5
5
  SHA512:
6
- metadata.gz: 11199b4b29998e62288777547706a6c545b2c0a2d74bf883a5ed5264031edca7d259fb702e131e473865aaff7f447d1fbdccb6c48a5786b3cda21dba23636afc
7
- data.tar.gz: 2789c1e753de096ce9b42a964e0daea6df2e542430d4ff8bd775eedae5db26ec5bf4ea17cfde021870d0f1c41869ce068d9f3230f3494a94fc3ec561d839a666
6
+ metadata.gz: '01874b1f9cad7364bf28af24830f62278c3e6aea796a5af4b66ca1fc5c3a63806f48fe3a44892f40c18759dabe58f825d444f28fb48f7b76777440c988120728'
7
+ data.tar.gz: 9c1c712c199f2abc7fa86c61d9739c1739d78200978071cb0b4ee0cb470091c5d84cf310f0a523f5cb31c98b87ed0ef2afd42ca61d3d743c7f605dde45b32663
data/Appraisals CHANGED
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "rails-5.1" do
4
- gem "activejob", "~> 5.1.6"
5
- gem "activesupport", "~> 5.1.6"
6
- end
7
-
8
3
  appraise "rails-5.2-sidekiq-5.0" do
9
4
  gem "activejob", "~> 5.2.0"
10
5
  gem "activesupport", "~> 5.2.0"
@@ -35,6 +30,18 @@ appraise "rails-5.2-sidekiq-6.1" do
35
30
  gem "sidekiq", "~> 6.1.0"
36
31
  end
37
32
 
33
+ appraise "rails-5.2-sidekiq-6.2" do
34
+ gem "activejob", "~> 5.2.0"
35
+ gem "activesupport", "~> 5.2.0"
36
+ gem "sidekiq", "~> 6.2.0"
37
+ end
38
+
39
+ appraise "rails-5.2-sidekiq-6.3" do
40
+ gem "activejob", "~> 5.2.0"
41
+ gem "activesupport", "~> 5.2.0"
42
+ gem "sidekiq", "~> 6.3.0"
43
+ end
44
+
38
45
  appraise "rails-6.0-sidekiq-5.2" do
39
46
  gem "activejob", "~> 6.0.0"
40
47
  gem "activesupport", "~> 6.0.0"
@@ -53,6 +60,18 @@ appraise "rails-6.0-sidekiq-6.1" do
53
60
  gem "sidekiq", "~> 6.1.0"
54
61
  end
55
62
 
63
+ appraise "rails-6.0-sidekiq-6.2" do
64
+ gem "activejob", "~> 6.0.0"
65
+ gem "activesupport", "~> 6.0.0"
66
+ gem "sidekiq", "~> 6.2.0"
67
+ end
68
+
69
+ appraise "rails-6.0-sidekiq-6.3" do
70
+ gem "activejob", "~> 6.0.0"
71
+ gem "activesupport", "~> 6.0.0"
72
+ gem "sidekiq", "~> 6.3.0"
73
+ end
74
+
56
75
  appraise "rails-6.1-sidekiq-5.2" do
57
76
  gem "activejob", "~> 6.1.0"
58
77
  gem "activesupport", "~> 6.1.0"
@@ -70,3 +89,15 @@ appraise "rails-6.1-sidekiq-6.1" do
70
89
  gem "activesupport", "~> 6.1.0"
71
90
  gem "sidekiq", "~> 6.1.0"
72
91
  end
92
+
93
+ appraise "rails-6.1-sidekiq-6.2" do
94
+ gem "activejob", "~> 6.1.0"
95
+ gem "activesupport", "~> 6.1.0"
96
+ gem "sidekiq", "~> 6.2.0"
97
+ end
98
+
99
+ appraise "rails-6.1-sidekiq-6.3" do
100
+ gem "activejob", "~> 6.1.0"
101
+ gem "activesupport", "~> 6.1.0"
102
+ gem "sidekiq", "~> 6.3.0"
103
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # sidekiq_publisher
2
2
 
3
+ ## 2.1.0
4
+ - Add support for sidekiq `7.0.0` by using `Sidekiq::Job` instead of
5
+ `Sidekiq::Worker` in sidekiq `>= 6.3.0` to handle name changes outlined in
6
+ mperham/sidekiq#4971 and first introduced in 6.2.2.
7
+
8
+ ## 2.0.1
9
+ - Changing the `Job#args` validator to be a manual check instead of using the `exclusions` validator. This is to fix an issue introduced with rails 6.1 and the condition of `in: [nil]`. More details [here](https://github.com/rails/rails/issues/41051).
10
+
11
+ ## v2.0.0
12
+ - Transition from defining a Railtie to becoming a Rails Engine
13
+ [(#44)](https://github.com/ezcater/sidekiq_publisher/pull/44). This change was
14
+ made to better support Ruby 3.0 and Rails 6.1. The change is *not* expected to
15
+ be breaking but it does represent a major change in the gem's implementation
16
+ and that is the reason for the major version bump.
17
+ - Require Ruby 2.6 or later.
18
+
3
19
  ## v1.8.0
4
20
  - Extend support to Rails 6.1.
5
21
 
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ezcater-production.jfrog.io/ruby:f08726283c
1
+ FROM ezcater-production.jfrog.io/ruby:90790156c4
2
2
  RUN mkdir /usr/src/gem
3
3
  WORKDIR /usr/src/gem
4
4
  ADD . /usr/src/gem
data/README.md CHANGED
@@ -138,22 +138,23 @@ end
138
138
 
139
139
  #### ActiveJob Exception Reporting
140
140
 
141
- Many exception monitoring service (e.g. Sentry, Airbrake, Honeybadger, etc) already provide basic integration support for `Sidekiq`.
142
- These integration should also work with `SidekiqPublisher`.
143
- However, you may need to explicitly include
141
+ Many exception monitoring service (e.g. Sentry, Airbrake, Honeybadger, etc) already provide basic integration support for `Sidekiq`.
142
+ These integration should also work with `SidekiqPublisher`.
143
+ However, you may need to explicitly include
144
144
  `ActiveJob::QueueAdapters::SidekiqPublisherAdapter` as a compatible adapter for this to work properly.
145
145
 
146
146
  Alternatively, you can manually report the exception:
147
147
 
148
148
  ```ruby
149
149
  retry_on SomeError, attempts: 10 do |_job, exception|
150
- Raven.capture_exception(exception, extra: { custom: :foo }) # Reporting using the Sentry gem
150
+ Raven.capture_exception(exception, extra: { custom: :foo }) # Reporting using the Sentry gem
151
151
  end
152
152
  ```
153
153
 
154
154
  ### SidekiqPublisher::Worker
155
155
 
156
- Sidekiq workers are usually defined by including `Sidekiq::Worker` in a class.
156
+ Sidekiq workers are usually defined by including `Sidekiq::Job` or
157
+ `Sidekiq::Worker` in a class.
157
158
 
158
159
  To use the `SidekiqPublisher`, this can be replaced by including
159
160
  `SidekiqPublisher::Worker`. The usual `perform_async`, etc methods will be
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_record"
4
-
5
3
  module SidekiqPublisher
6
4
  class Job < ActiveRecord::Base
7
5
  self.table_name = "sidekiq_publisher_jobs"
@@ -12,7 +10,11 @@ module SidekiqPublisher
12
10
  before_save :ensure_string_job_class
13
11
 
14
12
  validates :job_class, presence: true
15
- validates :args, exclusion: { in: [nil] }
13
+ # This exclusion rule currently has a bug in rails 6.1. For now, we will use a manual implementation
14
+ # Github Issue: https://github.com/rails/rails/issues/41051
15
+ # Possible PR: https://github.com/rails/rails/pull/41412
16
+ # validates :args, exclusion: { in: [nil] }
17
+ validate :args_not_nil
16
18
 
17
19
  scope :unpublished, -> { where(published_at: nil) }
18
20
  scope :published, -> { where.not(published_at: nil) }
@@ -56,6 +58,10 @@ module SidekiqPublisher
56
58
 
57
59
  private
58
60
 
61
+ def args_not_nil
62
+ errors.add(:args, "is reserved") if args.nil?
63
+ end
64
+
59
65
  def ensure_job_id
60
66
  self.job_id ||= self.class.generate_sidekiq_jid
61
67
  end
data/docker-compose.yml CHANGED
@@ -7,6 +7,7 @@ x-environment: &default-environment
7
7
  BUNDLE_IGNORE_CONFIG: 1
8
8
  BUNDLE_DISABLE_SHARED_GEMS: "true"
9
9
  PGUSER: postgres
10
+ PGPASSWORD: postgres
10
11
  PGHOST: sidekiq-publisher-postgres
11
12
  PGPORT: 5432
12
13
  PGDATABASE: sidekiq_publisher_test
@@ -28,9 +29,10 @@ services:
28
29
  image: redis:5.0.9-alpine
29
30
  sidekiq-publisher-postgres:
30
31
  container_name: sidekiq-publisher-postgres_1
31
- image: postgres:11.6
32
+ image: postgres:12.6
32
33
  environment:
33
34
  POSTGRES_USER: postgres
35
+ POSTGRES_PASSWORD: postgres
34
36
  POSTGRES_DB: sidekiq_publisher_test
35
37
  sidekiq-publisher-console:
36
38
  <<: *default-service
@@ -2,7 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activejob", "~> 5.1.6"
6
- gem "activesupport", "~> 5.1.6"
5
+ gem "activejob", "~> 5.2.0"
6
+ gem "activesupport", "~> 5.2.0"
7
+ gem "sidekiq", "~> 6.2.0"
7
8
 
8
9
  gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activejob", "~> 6.0.0"
6
+ gem "activesupport", "~> 6.0.0"
7
+ gem "sidekiq", "~> 6.2.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activejob", "~> 6.1.0"
6
+ gem "activesupport", "~> 6.1.0"
7
+ gem "sidekiq", "~> 6.2.0"
8
+
9
+ gemspec path: "../"
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_job/queue_adapters/sidekiq_adapter"
4
+ require "active_support/core_ext/object/blank"
4
5
 
5
6
  module ActiveJob
6
7
  module QueueAdapters
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SidekiqPublisher
4
+ module Compatibility
5
+ class << self
6
+ # Sidekiq::Worker will be renamed to Sidekiq::Job in sidekiq 7.0.0 and a
7
+ # deprecation warning will be printed in sidekiq 6.4.0, per
8
+ # mperham/sidekiq#4971. Sidekiq 6.2.2 (mperham/sidekiq@8e36432) introduces
9
+ # an alias and 6.3.0 includes it when the gem is loaded. This alias is
10
+ # used here to ensure future compatibility.
11
+ def sidekiq_job_class
12
+ @_sidekiq_job_class ||= Gem::Dependency.new("sidekiq", ">= 6.3.0").then do |dependency|
13
+ if dependency.match?(Gem.loaded_specs["sidekiq"])
14
+ Sidekiq::Job
15
+ else
16
+ Sidekiq::Worker
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqPublisher
4
- class Railtie < Rails::Railtie
5
- rake_tasks do
6
- load "sidekiq_publisher/tasks.rake"
7
- end
4
+ class Engine < Rails::Engine
5
+ isolate_namespace SidekiqPublisher
8
6
 
9
7
  initializer "sidekiq_publisher.configure" do
10
8
  SidekiqPublisher.logger = Rails.logger
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/subscriber"
4
+ require "active_support/core_ext/object/try"
4
5
 
5
6
  module SidekiqPublisher
6
7
  module MetricsReporter
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "sidekiq_publisher/client"
4
- require "active_support/core_ext/object/try"
4
+ require "active_support/core_ext/object/blank"
5
5
 
6
6
  module SidekiqPublisher
7
7
  class Publisher
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqPublisher
4
- VERSION = "1.8.0"
4
+ VERSION = "2.1.0"
5
5
  end
@@ -3,7 +3,7 @@
3
3
  module SidekiqPublisher
4
4
  module Worker
5
5
  def self.included(base)
6
- base.include(Sidekiq::Worker)
6
+ base.include(SidekiqPublisher::Compatibility.sidekiq_job_class)
7
7
  base.singleton_class.public_send(:alias_method, :sidekiq_client_push, :client_push)
8
8
  base.extend(ClassMethods)
9
9
  end
@@ -1,16 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support"
4
+ require "active_support/core_ext/numeric/time"
4
5
  require "sidekiq_publisher/version"
6
+ require "sidekiq_publisher/compatibility"
5
7
  require "sidekiq_publisher/instrumenter"
6
8
  require "sidekiq_publisher/metrics_reporter"
7
9
  require "sidekiq_publisher/exception_reporter"
8
10
  require "sidekiq_publisher/report_unpublished_count"
9
- require "sidekiq_publisher/job"
10
11
  require "sidekiq_publisher/worker"
11
12
  require "sidekiq_publisher/publisher"
12
13
  require "sidekiq_publisher/runner"
13
- require "sidekiq_publisher/railtie" if defined?(Rails)
14
+ require "sidekiq_publisher/engine" if defined?(Rails)
14
15
 
15
16
  module SidekiqPublisher
16
17
  DEFAULT_BATCH_SIZE = 100
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :sidekiq_publisher do
4
+ desc "Start the Sidekiq Publisher runner"
4
5
  task publish: [:environment] do
5
6
  Signal.trap("INT") { exit(0) }
6
7
  Signal.trap("TERM") { exit(0) }
@@ -41,6 +41,8 @@ Gem::Specification.new do |spec|
41
41
  spec.executables = []
42
42
  spec.require_paths = ["lib"]
43
43
 
44
+ spec.required_ruby_version = ">= 2.6"
45
+
44
46
  spec.add_development_dependency "activejob"
45
47
  spec.add_development_dependency "appraisal"
46
48
  spec.add_development_dependency "bundler", "~> 1.12"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-31 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -289,38 +289,41 @@ files:
289
289
  - Gemfile
290
290
  - LICENSE.txt
291
291
  - README.md
292
+ - app/models/sidekiq_publisher/job.rb
292
293
  - docker-compose.yml
293
- - gemfiles/rails_5.1.gemfile
294
294
  - gemfiles/rails_5.2.gemfile
295
295
  - gemfiles/rails_5.2_sidekiq_5.0.gemfile
296
296
  - gemfiles/rails_5.2_sidekiq_5.1.gemfile
297
297
  - gemfiles/rails_5.2_sidekiq_5.2.gemfile
298
298
  - gemfiles/rails_5.2_sidekiq_6.0.gemfile
299
299
  - gemfiles/rails_5.2_sidekiq_6.1.gemfile
300
+ - gemfiles/rails_5.2_sidekiq_6.2.gemfile
300
301
  - gemfiles/rails_6.0_sidekiq_5.2.gemfile
301
302
  - gemfiles/rails_6.0_sidekiq_6.0.gemfile
302
303
  - gemfiles/rails_6.0_sidekiq_6.1.gemfile
304
+ - gemfiles/rails_6.0_sidekiq_6.2.gemfile
303
305
  - gemfiles/rails_6.1_sidekiq_5.2.gemfile
304
306
  - gemfiles/rails_6.1_sidekiq_6.0.gemfile
305
307
  - gemfiles/rails_6.1_sidekiq_6.1.gemfile
308
+ - gemfiles/rails_6.1_sidekiq_6.2.gemfile
306
309
  - lib/active_job/queue_adapters/sidekiq_publisher_adapter.rb
307
310
  - lib/generators/sidekiq_publisher/install_generator.rb
308
311
  - lib/generators/sidekiq_publisher/templates/create_sidekiq_publisher_jobs.rb
309
312
  - lib/sidekiq_publisher.rb
310
313
  - lib/sidekiq_publisher/client.rb
314
+ - lib/sidekiq_publisher/compatibility.rb
311
315
  - lib/sidekiq_publisher/datadog_apm.rb
316
+ - lib/sidekiq_publisher/engine.rb
312
317
  - lib/sidekiq_publisher/exception_reporter.rb
313
318
  - lib/sidekiq_publisher/instrumenter.rb
314
- - lib/sidekiq_publisher/job.rb
315
319
  - lib/sidekiq_publisher/metrics_reporter.rb
316
320
  - lib/sidekiq_publisher/publisher.rb
317
- - lib/sidekiq_publisher/railtie.rb
318
321
  - lib/sidekiq_publisher/report_unpublished_count.rb
319
322
  - lib/sidekiq_publisher/runner.rb
320
- - lib/sidekiq_publisher/tasks.rake
321
323
  - lib/sidekiq_publisher/testing.rb
322
324
  - lib/sidekiq_publisher/version.rb
323
325
  - lib/sidekiq_publisher/worker.rb
326
+ - lib/tasks/sidekiq_publisher.rake
324
327
  - log/.gitkeep
325
328
  - sidekiq_publisher.gemspec
326
329
  homepage: https://github.com/ezcater/sidekiq_publisher
@@ -328,7 +331,7 @@ licenses:
328
331
  - MIT
329
332
  metadata:
330
333
  allowed_push_host: https://rubygems.org
331
- post_install_message:
334
+ post_install_message:
332
335
  rdoc_options: []
333
336
  require_paths:
334
337
  - lib
@@ -336,16 +339,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
336
339
  requirements:
337
340
  - - ">="
338
341
  - !ruby/object:Gem::Version
339
- version: '0'
342
+ version: '2.6'
340
343
  required_rubygems_version: !ruby/object:Gem::Requirement
341
344
  requirements:
342
345
  - - ">="
343
346
  - !ruby/object:Gem::Version
344
347
  version: '0'
345
348
  requirements: []
346
- rubyforge_project:
347
- rubygems_version: 2.7.6.2
348
- signing_key:
349
+ rubygems_version: 3.1.4
350
+ signing_key:
349
351
  specification_version: 4
350
352
  summary: Publisher for enqueuing jobs to Sidekiq
351
353
  test_files: []