1
0
Fork 0
mirror of https://github.com/deanpcmad/sidekiq-limit_fetch.git synced 2022-11-09 13:54:36 -05:00

Add demo tasks for blocking and advanced blocking

This commit is contained in:
brainopia 2014-03-12 12:34:32 +04:00
parent 160f91792e
commit 22d3cac2c8
4 changed files with 65 additions and 2 deletions

View file

@ -22,6 +22,45 @@ namespace :demo do
YAML
end
task blocking: :environment do
puts '=> Creating sidekiq tasks'
AWorker.perform_async
BWorker.perform_async
CWorker.perform_async
run_sidekiq_monitoring
run_sidekiq_workers config: <<-YAML
:verbose: false
:concurrency: 4
:queues:
- a
- b
- c
:blocking:
- a
YAML
end
task advanced_blocking: :environment do
puts '=> Creating sidekiq tasks'
AWorker.perform_async
BWorker.perform_async
CWorker.perform_async
run_sidekiq_monitoring
run_sidekiq_workers config: <<-YAML
:verbose: false
:concurrency: 4
:queues:
- a
- b
- c
:blocking:
- [a, b]
YAML
end
def with_sidekiq_config(config)
whitespace_offset = config[/\A */].size
config.gsub! /^ {#{whitespace_offset}}/, ''
@ -51,8 +90,7 @@ namespace :demo do
end
with_sidekiq_config options[:config] do
config = cli.send :parse_config, 'config/sidekiq.yml'
Sidekiq.options.merge! config
cli.send :setup_options, []
end
cli.run

View file

@ -0,0 +1,8 @@
class AWorker
include Sidekiq::Worker
sidekiq_options queue: :a
def perform
sleep 10
end
end

View file

@ -0,0 +1,8 @@
class BWorker
include Sidekiq::Worker
sidekiq_options queue: :b
def perform
sleep 10
end
end

View file

@ -0,0 +1,9 @@
class CWorker
include Sidekiq::Worker
sidekiq_options queue: :c
def perform
sleep 10
end
end