sidekiq-queue-throttled 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 845429390d0f00efb237293d8605132320537f14ae86229661944dd80fd0a150
4
- data.tar.gz: 8e7651a3296a150b19a1da63d3ffce8006a78b9c640acb5632897786709008fb
3
+ metadata.gz: b1220e8680f9582d2cddf183688e3a1417679eda0f3be0295b795c786ad77d48
4
+ data.tar.gz: c7302965fc700ca799eca0ee350a63b959b0382f90d570c3340caf7d7dfbce4e
5
5
  SHA512:
6
- metadata.gz: 6c3c10007aea863ef7c79a1aba9675cfff45bc5db80933d661ac398974a7fe8c06007c654c930e4644593a57a5f3adddf4aa14d90ba520cadde8373a52dfeaf1
7
- data.tar.gz: b3e5450ad52d117abbab89f498ca8825e2f0ff9e692c5989dd55777b1887d9bc0868880a2bdb7eb8321d0b68c7f97775e8b6b1cbe1186f244596c8e8081214e2
6
+ metadata.gz: cfcc33a8ba102433229a9c6146484618c04eb6b1b5afe691520d863c5a0f10a6e671b399946deda24bb4365ec21968ebd21dda8952503bcef51deb3bb103cd59
7
+ data.tar.gz: b89b70d7e26781126ff5cbfa72546acb974923d9142113b1f06462268896d3ee3ee5c12da995aa8442b43aaf84401e587062514ee57946da81cd932cf5167620
data/README.md CHANGED
@@ -25,6 +25,18 @@ And then execute:
25
25
  $ bundle install
26
26
  ```
27
27
 
28
+ ### Rails Applications
29
+
30
+ For Rails applications, the gem will be automatically loaded when your application starts. No additional configuration is required.
31
+
32
+ ### Non-Rails Applications
33
+
34
+ For non-Rails applications, you need to explicitly require the gem:
35
+
36
+ ```ruby
37
+ require 'sidekiq/queue_throttled'
38
+ ```
39
+
28
40
  ## Configuration
29
41
 
30
42
  ### Queue Limits
@@ -286,6 +298,30 @@ end
286
298
  - **Network Latency**: Consider Redis network latency when setting TTL values
287
299
  - **Concurrent Access**: The gem uses thread-safe primitives for concurrent access
288
300
 
301
+ ## Troubleshooting
302
+
303
+ ### "uninitialized constant Sidekiq::QueueThrottled" Error
304
+
305
+ If you encounter this error when trying to use the gem:
306
+
307
+ ```
308
+ uninitialized constant Sidekiq::QueueThrottled (NameError)
309
+ ```
310
+
311
+ **For Rails applications:**
312
+ - Make sure the gem is properly added to your Gemfile
313
+ - Restart your Rails server after adding the gem
314
+ - The gem should auto-load when your Rails application starts
315
+
316
+ **For non-Rails applications:**
317
+ - Explicitly require the gem at the top of your file:
318
+ ```ruby
319
+ require 'sidekiq/queue_throttled'
320
+ ```
321
+
322
+ **For IRB/Console:**
323
+ - If you're testing in IRB or Rails console, make sure to restart the console after adding the gem to your Gemfile
324
+
289
325
  ## Contributing
290
326
 
291
327
  1. Fork the repository
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails'
4
+
5
+ module Sidekiq
6
+ module QueueThrottled
7
+ class Railtie < ::Rails::Railtie
8
+ initializer 'sidekiq.queue_throttled' do
9
+ require 'sidekiq/queue_throttled'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module QueueThrottled
5
- VERSION = '1.1.3'
5
+ VERSION = '1.1.5'
6
6
  end
7
7
  end
@@ -13,6 +13,14 @@ require_relative 'queue_throttled/job_throttler'
13
13
  require_relative 'queue_throttled/middleware'
14
14
  require_relative 'queue_throttled/job'
15
15
 
16
+ # Auto-load Rails integration if Rails is available
17
+ begin
18
+ require 'rails'
19
+ require_relative 'queue_throttled/railtie'
20
+ rescue LoadError
21
+ # Rails is not available, which is fine for non-Rails applications
22
+ end
23
+
16
24
  module Sidekiq
17
25
  module QueueThrottled
18
26
  class << self
data/spec/examples.txt CHANGED
@@ -108,3 +108,8 @@ example_id | status | run_tim
108
108
  ./spec/sidekiq/queue_throttled/queue_limiter_spec.rb[1:7:2] | passed | 0.00131 seconds |
109
109
  ./spec/sidekiq/queue_throttled/queue_limiter_spec.rb[1:8:1] | passed | 0.00045 seconds |
110
110
  ./spec/sidekiq/queue_throttled/queue_limiter_spec.rb[1:8:2] | passed | 0.0008 seconds |
111
+ ./spec/sidekiq/queue_throttled/railtie_spec.rb[1:1:1] | failed | 0.00014 seconds |
112
+ ./spec/sidekiq/queue_throttled/railtie_spec.rb[1:1:2] | failed | 0.00011 seconds |
113
+ ./spec/sidekiq/queue_throttled/railtie_spec.rb[1:1:3] | failed | 0.00011 seconds |
114
+ ./spec/sidekiq/queue_throttled/railtie_spec.rb[1:2:1] | failed | 0.00128 seconds |
115
+ ./spec/sidekiq/queue_throttled/railtie_spec.rb[1:2:2] | failed | 0.00021 seconds |
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe 'Rails Integration' do
6
+ describe 'when Rails is available' do
7
+ before do
8
+ # Mock Rails to simulate Rails environment
9
+ stub_const('Rails', double('Rails'))
10
+ stub_const('Rails::Railtie', Class.new)
11
+
12
+ # Reload the main file to trigger Rails detection
13
+ load File.expand_path('../../lib/sidekiq/queue_throttled.rb', __dir__)
14
+ end
15
+
16
+ it 'defines the Sidekiq::QueueThrottled module' do
17
+ expect(defined?(Sidekiq::QueueThrottled)).to be_truthy
18
+ end
19
+
20
+ it 'defines the Sidekiq::QueueThrottled::Job module' do
21
+ expect(defined?(Sidekiq::QueueThrottled::Job)).to be_truthy
22
+ end
23
+
24
+ it 'defines the Railtie class' do
25
+ expect(defined?(Sidekiq::QueueThrottled::Railtie)).to be_truthy
26
+ end
27
+ end
28
+
29
+ describe 'when Rails is not available' do
30
+ before do
31
+ # Remove Rails constants to simulate non-Rails environment
32
+ Object.send(:remove_const, 'Rails') if defined?(Rails)
33
+
34
+ # Reload the main file to trigger Rails detection
35
+ load File.expand_path('../../lib/sidekiq/queue_throttled.rb', __dir__)
36
+ end
37
+
38
+ it 'still defines the Sidekiq::QueueThrottled module' do
39
+ expect(defined?(Sidekiq::QueueThrottled)).to be_truthy
40
+ end
41
+
42
+ it 'still defines the Sidekiq::QueueThrottled::Job module' do
43
+ expect(defined?(Sidekiq::QueueThrottled::Job)).to be_truthy
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-queue-throttled
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Farid Mohammadi
@@ -70,6 +70,7 @@ files:
70
70
  - lib/sidekiq/queue_throttled/job_throttler.rb
71
71
  - lib/sidekiq/queue_throttled/middleware.rb
72
72
  - lib/sidekiq/queue_throttled/queue_limiter.rb
73
+ - lib/sidekiq/queue_throttled/railtie.rb
73
74
  - lib/sidekiq/queue_throttled/version.rb
74
75
  - spec/examples.txt
75
76
  - spec/sidekiq/queue_throttled/configuration_spec.rb
@@ -77,6 +78,7 @@ files:
77
78
  - spec/sidekiq/queue_throttled/job_throttler_spec.rb
78
79
  - spec/sidekiq/queue_throttled/middleware_spec.rb
79
80
  - spec/sidekiq/queue_throttled/queue_limiter_spec.rb
81
+ - spec/sidekiq/queue_throttled/railtie_spec.rb
80
82
  - spec/spec_helper.rb
81
83
  homepage: https://github.com/zilnex/sidekiq-queue-throttled
82
84
  licenses: