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 @@ -21,13 +21,17 @@ task :web do
2121 }
2222 end
2323
24- # throw a fake job in
24+ # throw some fake jobs in
2525 Sidecloq . configure do |config |
2626 sched = Sidecloq ::Schedule . from_hash ( {
2727 my_scheduled_job : {
2828 class : 'DoWork' ,
2929 cron : '* * * * *' ,
3030 queue : 'default'
31+ } ,
32+ my_scheduled_job2 : {
33+ class : 'DoWorkWithQueue' ,
34+ cron : '* * * * *'
3135 }
3236 } )
3337 sched . save_redis
@@ -38,6 +42,11 @@ task :web do
3842 include Sidekiq ::Worker
3943 end
4044
45+ class DoWorkWithQueue
46+ include Sidekiq ::Worker
47+ sidekiq_options queue : "not_default"
48+ end
49+
4150 require 'rack/server'
4251 require 'rack/session/cookie'
4352 require 'sidekiq/web'
Original file line number Diff line number Diff line change @@ -6,7 +6,15 @@ module Web
66
77 def self . registered ( app )
88 app . get '/recurring' do
9- @schedule = Schedule . from_redis
9+ @job_specs = Schedule . from_redis . job_specs
10+ @job_specs . each_value do |job_spec |
11+ job_spec [ 'cron' ] ||= job_spec [ 'every' ]
12+
13+ job_spec [ 'queue' ] ||= begin
14+ klass = Object . const_get ( job_spec [ 'class' ] )
15+ ( klass . sidekiq_options_hash && klass . sidekiq_options_hash . fetch ( 'queue' , 'default' ) ) || 'default'
16+ end
17+ end
1018
1119 erb File . read ( File . join ( VIEW_PATH , 'recurring.erb' ) )
1220 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