1+ # frozen_string_literal: true
2+
13require 'benchmark'
24require 'sidekiq/cli'
35require 'sidekiq/api'
911if limit
1012 limit = nil if limit == 'nil'
1113
12- $: . unshift File . expand_path '../lib'
14+ $LOAD_PATH . unshift File . expand_path '../lib'
1315 require 'sidekiq-limit_fetch'
1416 Sidekiq ::Queue [ 'inline' ] . limit = limit
15- Sidekiq . redis { |it | it . del 'limit_fetch:probed:inline' }
16- Sidekiq ::LimitFetch ::Queues . send ( :define_method , :set ) { |*| }
17+ Sidekiq . redis { |it | it . del 'limit_fetch:probed:inline' }
18+ Sidekiq ::LimitFetch ::Queues . send ( :define_method , :set ) { |*| } # rubocop:disable Lint/EmptyBlock
1719end
1820
1921Sidekiq ::Queue . new ( 'inline' ) . clear
@@ -22,8 +24,8 @@ class FastJob
2224 include Sidekiq ::Worker
2325 sidekiq_options queue : :inline
2426
25- def perform ( i )
26- puts "job N#{ i } is finished"
27+ def perform ( index )
28+ puts "job N#{ index } is finished"
2729 end
2830end
2931
@@ -36,17 +38,19 @@ def perform
3638 end
3739end
3840
39- total . times { |i | FastJob . perform_async i + 1 }
41+ total . times { |i | FastJob . perform_async i + 1 }
4042FinishJob . perform_async
4143
4244Sidekiq ::CLI . instance . tap do |cli |
43- %w( validate! boot_system ) . each { |stub | cli . define_singleton_method ( stub ) { } }
45+ %w[ validate! boot_system ] . each { |stub | cli . define_singleton_method ( stub ) { } } # rubocop:disable Lint/EmptyBlock
4446 cli . parse [ '-q inline' , '-q other' , "-c #{ concurrency } " ]
4547
46- puts Benchmark . measure {
47- begin
48- cli . run
49- rescue Exception
50- end
51- }
48+ # rubocop:disable Lint/RescueException
49+ # rubocop:disable Lint/SuppressedException
50+ puts Benchmark . measure do
51+ cli . run
52+ rescue Exception
53+ end
54+ # rubocop:enable Lint/SuppressedException
55+ # rubocop:enable Lint/RescueException
5256end
0 commit comments