blob: 507b154e0df4af529c2761cfd0c90e7ce34f460b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module ActionCable
class Server
cattr_accessor(:logger, instance_reader: true) { Rails.logger }
attr_accessor :registered_channels, :redis_config
def initialize(redis_config:, channels:, worker_pool_size: 100, connection: Connection)
@redis_config = redis_config.with_indifferent_access
@registered_channels = Set.new(channels)
@worker_pool_size = worker_pool_size
@connection_class = connection
logger.info "[ActionCable] Initialized server (redis_config: #{@redis_config.inspect}, worker_pool_size: #{@worker_pool_size})"
end
def call(env)
@connection_class.new(self, env).process
end
def worker_pool
@worker_pool ||= ActionCable::Worker.pool(size: @worker_pool_size)
end
def pubsub
@pubsub ||= EM::Hiredis.connect(@redis_config[:url]).pubsub
end
def remote_connections
@remote_connections ||= RemoteConnections.new(self)
end
def connection_identifiers
@connection_class.identifiers
end
end
end
|