aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/stubs/test_server.rb
blob: 5916cf1e8393ee3d62d5c830a7f39647249d5855 (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
require 'ostruct'

class TestServer
  include ActionCable::Server::Connections

  attr_reader :logger, :config

  def initialize
    @logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
    @config = OpenStruct.new(log_tags: [], subscription_adapter: SuccessAdapter)
  end

  def pubsub
    @config.subscription_adapter.new(self)
  end

  def stream_event_loop
    @stream_event_loop ||= ActionCable::Connection::StreamEventLoop.new
  end

  def worker_pool
    @worker_pool ||= ActionCable::Server::Worker.new(max_size: 5)
  end
end