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 @@ -21,13 +21,17 @@ task :web do
21
21
}
22
22
end
23
23
24
- # throw a fake job in
24
+ # throw some fake jobs in
25
25
Sidecloq . configure do |config |
26
26
sched = Sidecloq ::Schedule . from_hash ( {
27
27
my_scheduled_job : {
28
28
class : 'DoWork' ,
29
29
cron : '* * * * *' ,
30
30
queue : 'default'
31
+ } ,
32
+ my_scheduled_job2 : {
33
+ class : 'DoWorkWithQueue' ,
34
+ cron : '* * * * *'
31
35
}
32
36
} )
33
37
sched . save_redis
@@ -38,6 +42,11 @@ task :web do
38
42
include Sidekiq ::Worker
39
43
end
40
44
45
+ class DoWorkWithQueue
46
+ include Sidekiq ::Worker
47
+ sidekiq_options queue : "not_default"
48
+ end
49
+
41
50
require 'rack/server'
42
51
require 'rack/session/cookie'
43
52
require 'sidekiq/web'
Original file line number Diff line number Diff line change @@ -6,7 +6,15 @@ module Web
6
6
7
7
def self . registered ( app )
8
8
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
10
18
11
19
erb File . read ( File . join ( VIEW_PATH , 'recurring.erb' ) )
12
20
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