mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Configurable worker pool size
This commit is contained in:
parent
b67b197564
commit
41e4396a55
2 changed files with 10 additions and 5 deletions
|
@ -67,7 +67,7 @@ module ActionCable
|
|||
def start_periodic_timers
|
||||
self.class.periodic_timers.each do |callback, options|
|
||||
@_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) do
|
||||
Celluloid::Actor[:worker_pool].async.run_periodic_timer(self, callback)
|
||||
connection.class.worker_pool.async.run_periodic_timer(self, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
Celluloid::Actor[:worker_pool] = ActionCable::Worker.pool(size: 100)
|
||||
|
||||
module ActionCable
|
||||
class Server
|
||||
class_attribute :registered_channels
|
||||
self.registered_channels = Set.new
|
||||
|
||||
class_attribute :worker_pool_size
|
||||
self.worker_pool_size = 100
|
||||
|
||||
class << self
|
||||
def register_channels(*channel_classes)
|
||||
self.registered_channels += channel_classes
|
||||
|
@ -13,6 +14,10 @@ module ActionCable
|
|||
def call(env)
|
||||
new(env).process
|
||||
end
|
||||
|
||||
def worker_pool
|
||||
@worker_pool ||= ActionCable::Worker.pool(size: worker_pool_size)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(env)
|
||||
|
@ -27,11 +32,11 @@ module ActionCable
|
|||
|
||||
@websocket.on(:message) do |event|
|
||||
message = event.data
|
||||
Celluloid::Actor[:worker_pool].async.received_data(self, message) if message.is_a?(String)
|
||||
self.class.worker_pool.async.received_data(self, message) if message.is_a?(String)
|
||||
end
|
||||
|
||||
@websocket.on(:close) do |event|
|
||||
Celluloid::Actor[:worker_pool].async.cleanup_subscriptions(self)
|
||||
self.class.worker_pool.async.cleanup_subscriptions(self)
|
||||
end
|
||||
|
||||
@websocket.rack_response
|
||||
|
|
Loading…
Reference in a new issue