sidekiq-queue-throttled 1.1.3 → 1.1.4
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 +4 -4
- data/README.md +36 -0
- data/lib/sidekiq/queue_throttled/railtie.rb +13 -0
- data/lib/sidekiq/queue_throttled/version.rb +1 -1
- data/lib/sidekiq/queue_throttled.rb +8 -0
- data/spec/examples.txt +5 -0
- data/spec/sidekiq/queue_throttled/railtie_spec.rb +46 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b658041cc8f4b7cb1cd5055c8371e3c672c4f74f9151faf5a67dda68f014d6ac
|
4
|
+
data.tar.gz: 36afa33c4f2250d70bf55c52318fbedbe2a10e6a629c557d676b81bd1fadf485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f6c4dc62bbd48be8646598d3e8aca5cb3baa2572bd80082c121fe140a7e13369694ef5420ecafd169fceb46344efec250d02a6398b8b7ac955b952faf33b710
|
7
|
+
data.tar.gz: deb6e902be8ea36f1b63a7bf630bcd8c28800360713349fa18a8f4ab07be142638d8437fb8e6e5ec5b7c0501aaab14be23f0a19b06b692fc53d87ba5e6fa995c
|
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
|
@@ -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.
|
4
|
+
version: 1.1.4
|
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:
|