File tree 3 files changed +22
-5
lines changed
3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,17 @@ task :web do
22
22
}
23
23
end
24
24
25
- # throw a fake job in
25
+ # throw some fake jobs in
26
26
Sidecloq . configure do |config |
27
27
sched = Sidecloq ::Schedule . from_hash ( {
28
28
my_scheduled_job : {
29
29
class : 'DoWork' ,
30
30
cron : '* * * * *' ,
31
31
queue : 'default'
32
+ } ,
33
+ my_scheduled_job2 : {
34
+ class : 'DoWorkWithQueue' ,
35
+ cron : '* * * * *'
32
36
}
33
37
} )
34
38
sched . save_redis
@@ -39,6 +43,11 @@ task :web do
39
43
include Sidekiq ::Worker
40
44
end
41
45
46
+ class DoWorkWithQueue
47
+ include Sidekiq ::Worker
48
+ sidekiq_options queue : "not_default"
49
+ end
50
+
42
51
require 'sidekiq/web'
43
52
require 'sidecloq/web'
44
53
require 'securerandom'
Original file line number Diff line number Diff line change @@ -5,7 +5,15 @@ module Web
5
5
6
6
def self . registered ( app )
7
7
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
9
17
10
18
erb File . read ( File . join ( VIEW_PATH , 'recurring.erb' ) )
11
19
end
Original file line number Diff line number Diff line change 14
14
</ thead >
15
15
16
16
< tbody >
17
- <% @schedule . job_specs . each do |name , job_spec | %>
17
+ <% @job_specs . each do |name , job_spec | %>
18
18
< tr >
19
19
< td > <%= name %> </ td >
20
- < td > <%= job_spec . fetch 'cron' , job_spec [ 'every '] %> </ td >
20
+ < td > <%= job_spec [ 'cron '] %> </ td >
21
21
< td > <%= job_spec [ 'class' ] %> </ td >
22
22
< 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 >
24
24
</ td >
25
25
< td > <%= job_spec [ 'args' ] %> </ td >
26
26
< td >
You can’t perform that action at this time.
0 commit comments