File tree Expand file tree Collapse file tree 4 files changed +17
-19
lines changed Expand file tree Collapse file tree 4 files changed +17
-19
lines changed Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module SolidQueue
4
- class Dispatcher < Processes ::Base
5
- include Processes ::Poller
6
-
4
+ class Dispatcher < Processes ::Poller
7
5
attr_accessor :batch_size , :concurrency_maintenance , :recurring_schedule
8
6
9
7
after_boot :start_concurrency_maintenance , :load_recurring_schedule
@@ -13,10 +11,11 @@ def initialize(**options)
13
11
options = options . dup . with_defaults ( SolidQueue ::Configuration ::DISPATCHER_DEFAULTS )
14
12
15
13
@batch_size = options [ :batch_size ]
16
- @polling_interval = options [ :polling_interval ]
17
14
18
15
@concurrency_maintenance = ConcurrencyMaintenance . new ( options [ :concurrency_maintenance_interval ] , options [ :batch_size ] ) if options [ :concurrency_maintenance ]
19
16
@recurring_schedule = RecurringSchedule . new ( options [ :recurring_tasks ] )
17
+
18
+ super ( **options )
20
19
end
21
20
22
21
def metadata
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module SolidQueue ::Processes
4
- module Poller
5
- extend ActiveSupport ::Concern
6
-
4
+ class Poller < Base
7
5
include Runnable
8
6
9
- included do
10
- attr_accessor :polling_interval
7
+ attr_accessor :polling_interval
8
+
9
+ def initialize ( polling_interval :, **options )
10
+ @polling_interval = polling_interval
11
11
end
12
12
13
13
def metadata
@@ -16,11 +16,7 @@ def metadata
16
16
17
17
private
18
18
def run
19
- if mode . async?
20
- @thread = Thread . new { start_loop }
21
- else
22
- start_loop
23
- end
19
+ start_loop
24
20
end
25
21
26
22
def start_loop
Original file line number Diff line number Diff line change @@ -13,7 +13,11 @@ def start
13
13
run_callbacks ( :boot ) { boot }
14
14
end
15
15
16
- run
16
+ if mode . async?
17
+ @thread = Thread . new { run }
18
+ else
19
+ run
20
+ end
17
21
end
18
22
19
23
def stop
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module SolidQueue
4
- class Worker < Processes ::Base
5
- include Processes ::Poller
6
-
4
+ class Worker < Processes ::Poller
7
5
attr_accessor :queues , :pool
8
6
9
7
def initialize ( **options )
10
8
options = options . dup . with_defaults ( SolidQueue ::Configuration ::WORKER_DEFAULTS )
11
9
12
- @polling_interval = options [ :polling_interval ]
13
10
@queues = Array ( options [ :queues ] )
14
11
@pool = Pool . new ( options [ :threads ] , on_idle : -> { wake_up } )
12
+
13
+ super ( **options )
15
14
end
16
15
17
16
def metadata
You can’t perform that action at this time.
0 commit comments