File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed
Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,17 @@ task :web do
2222 }
2323 end
2424
25- # throw a fake job in
25+ # throw some fake jobs in
2626 Sidecloq . configure do |config |
2727 sched = Sidecloq ::Schedule . from_hash ( {
2828 my_scheduled_job : {
2929 class : 'DoWork' ,
3030 cron : '* * * * *' ,
3131 queue : 'default'
32+ } ,
33+ my_scheduled_job2 : {
34+ class : 'DoWorkWithQueue' ,
35+ cron : '* * * * *'
3236 }
3337 } )
3438 sched . save_redis
@@ -39,6 +43,11 @@ task :web do
3943 include Sidekiq ::Worker
4044 end
4145
46+ class DoWorkWithQueue
47+ include Sidekiq ::Worker
48+ sidekiq_options queue : "not_default"
49+ end
50+
4251 require 'sidekiq/web'
4352 require 'sidecloq/web'
4453 require 'securerandom'
Original file line number Diff line number Diff line change @@ -5,7 +5,15 @@ module Web
55
66 def self . registered ( app )
77 app . get '/recurring' do
8- @schedule = Schedule . from_redis
8+ @job_specs = Schedule . from_redis . job_specs
9+ @job_specs . each_value do |job_spec |
10+ job_spec [ 'cron' ] ||= job_spec [ 'every' ]
11+
12+ job_spec [ 'queue' ] ||= begin
13+ klass = Object . const_get ( job_spec [ 'class' ] )
14+ ( klass . sidekiq_options_hash && klass . sidekiq_options_hash . fetch ( 'queue' , 'default' ) ) || 'default'
15+ end
16+ end
917
1018 erb File . read ( File . join ( VIEW_PATH , 'recurring.erb' ) )
1119 end
Original file line number Diff line number Diff line change 1414 </ thead >
1515
1616 < tbody >
17- <% @schedule . job_specs . each do |name , job_spec | %>
17+ <% @job_specs . each do |name , job_spec | %>
1818 < tr >
1919 < td > <%= name %> </ td >
20- < td > <%= job_spec . fetch 'cron' , job_spec [ 'every '] %> </ td >
20+ < td > <%= job_spec [ 'cron '] %> </ td >
2121 < td > <%= job_spec [ 'class' ] %> </ td >
2222 < td >
23- < a href ="<%= root_path %> queues/ <%= job_spec . fetch ( 'queue' , 'default' ) %> "> <%= job_spec . fetch ( 'queue' , 'default' ) %> </ a >
23+ < a href ="<%= root_path %> queues/ <%= job_spec [ 'queue' ] %> "> <%= job_spec [ 'queue' ] %> </ a >
2424 </ td >
2525 < td > <%= job_spec [ 'args' ] %> </ td >
2626 < td >
You can’t perform that action at this time.
0 commit comments