-
Notifications
You must be signed in to change notification settings - Fork 59
Batch delete from web fix, Start gem improved, Support Sidekiq 8 #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 10 commits
4158463
84a3ad5
4497cab
05d3138
6afcfc6
4f2ca94
8bbd238
1865595
ad3ed63
736b028
59751c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,38 +3,43 @@ | |
| module Sidekiq | ||
| module Grouping | ||
| module Config | ||
| include ActiveSupport::Configurable | ||
|
|
||
| def self.options | ||
| if Sidekiq.respond_to?(:[]) # Sidekiq 6.x | ||
| Sidekiq[:grouping] || {} | ||
| elsif Sidekiq.respond_to?(:options) # Sidekiq <= 5.x | ||
| Sidekiq.options[:grouping] || Sidekiq.options["grouping"] || {} | ||
| else # Sidekiq 7.x | ||
| Sidekiq.default_configuration[:grouping] || {} | ||
| class << self | ||
| %i[lock_ttl max_batch_size poll_interval tests_env].each do |method_name| | ||
| define_method(method_name) do | ||
| config[method_name] | ||
| end | ||
| define_method(:"#{method_name}=") do |value| | ||
| config[method_name] = value | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # Queue size overflow check polling interval | ||
| config_accessor :poll_interval do | ||
| options[:poll_interval] || 3 | ||
| end | ||
|
|
||
| # Maximum batch size | ||
| config_accessor :max_batch_size do | ||
| options[:max_batch_size] || 1000 | ||
| end | ||
| private | ||
|
|
||
| # Batch queue flush lock timeout | ||
| config_accessor :lock_ttl do | ||
| options[:lock_ttl] || 1 | ||
| end | ||
| def config | ||
| @config ||= ActiveSupport::InheritableOptions.new( | ||
| lock_ttl: options[:lock_ttl] || 1, | ||
| max_batch_size: options[:max_batch_size] || 1_000, | ||
| poll_interval: options[:poll_interval] || 3, | ||
| tests_env: options[:tests_env] || ( | ||
| defined?(::Rails) && ::Rails.respond_to?(:env) && ::Rails.env.test? | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/LineLength: Line is too long. [81/80] |
||
| ) | ||
| ) | ||
| end | ||
|
|
||
| # Option to override how Sidekiq::Grouping know about tests env | ||
| config_accessor :tests_env do | ||
| options[:tests_env] || ( | ||
| defined?(::Rails) && Rails.respond_to?(:env) && Rails.env.test? | ||
| ) | ||
| def options | ||
| @options ||= | ||
| begin | ||
| if Sidekiq.respond_to?(:[]) # Sidekiq 6.x | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/IndentationWidth: Use 2 (not 3) spaces for indentation. |
||
| Sidekiq[:grouping] || {} | ||
| elsif Sidekiq.respond_to?(:options) # Sidekiq <= 5.x | ||
| Sidekiq.options[:grouping] || Sidekiq.options["grouping"] || {} | ||
| elsif Sidekiq.server? # Sidekiq >= 7.x | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/ExtraSpacing: Unnecessary spacing detected. |
||
| Sidekiq::CLI.instance.config[:grouping] | ||
| else | ||
| Sidekiq.default_configuration[:grouping] || {} | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [81/80]