Remove Faye mode
No deprecation, because it was never documented.
This commit is contained in:
parent
9588a3d66d
commit
d44177d45e
|
@ -36,9 +36,7 @@ env:
|
||||||
- "GEM=railties"
|
- "GEM=railties"
|
||||||
- "GEM=ap"
|
- "GEM=ap"
|
||||||
- "GEM=ac"
|
- "GEM=ac"
|
||||||
- "GEM=ac FAYE=1"
|
|
||||||
- "GEM=ac:integration"
|
- "GEM=ac:integration"
|
||||||
- "GEM=ac:integration FAYE=1"
|
|
||||||
- "GEM=am,amo,as,av,aj"
|
- "GEM=am,amo,as,av,aj"
|
||||||
- "GEM=as PRESERVE_TIMEZONES=1"
|
- "GEM=as PRESERVE_TIMEZONES=1"
|
||||||
- "GEM=ar:mysql2"
|
- "GEM=ar:mysql2"
|
||||||
|
@ -69,7 +67,6 @@ matrix:
|
||||||
- rvm: ruby-head
|
- rvm: ruby-head
|
||||||
- rvm: jruby-9.0.5.0
|
- rvm: jruby-9.0.5.0
|
||||||
- env: "GEM=ac:integration"
|
- env: "GEM=ac:integration"
|
||||||
- env: "GEM=ac:integration FAYE=1"
|
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
|
|
4
Rakefile
4
Rakefile
|
@ -23,9 +23,6 @@ task default: %w(test test:isolated)
|
||||||
FRAMEWORKS.each do |project|
|
FRAMEWORKS.each do |project|
|
||||||
system(%(cd #{project} && #{$0} #{task_name} --trace)) || errors << project
|
system(%(cd #{project} && #{$0} #{task_name} --trace)) || errors << project
|
||||||
end
|
end
|
||||||
if task_name =~ /test/
|
|
||||||
system(%(cd actioncable && env FAYE=1 #{$0} #{task_name} --trace)) || errors << "actioncable-faye"
|
|
||||||
end
|
|
||||||
fail("Errors in #{errors.join(', ')}") unless errors.empty?
|
fail("Errors in #{errors.join(', ')}") unless errors.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -36,7 +33,6 @@ task :smoke do
|
||||||
system %(cd #{project} && #{$0} test:isolated --trace)
|
system %(cd #{project} && #{$0} test:isolated --trace)
|
||||||
end
|
end
|
||||||
system %(cd activerecord && #{$0} sqlite3:isolated_test --trace)
|
system %(cd activerecord && #{$0} sqlite3:isolated_test --trace)
|
||||||
system %(cd actioncable && env FAYE=1 #{$0} test:isolated --trace)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Install gems for all projects."
|
desc "Install gems for all projects."
|
||||||
|
|
|
@ -8,8 +8,6 @@ module ActionCable
|
||||||
autoload :ClientSocket
|
autoload :ClientSocket
|
||||||
autoload :Identification
|
autoload :Identification
|
||||||
autoload :InternalChannel
|
autoload :InternalChannel
|
||||||
autoload :FayeClientSocket
|
|
||||||
autoload :FayeEventLoop
|
|
||||||
autoload :MessageBuffer
|
autoload :MessageBuffer
|
||||||
autoload :Stream
|
autoload :Stream
|
||||||
autoload :StreamEventLoop
|
autoload :StreamEventLoop
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
require "faye/websocket"
|
|
||||||
|
|
||||||
module ActionCable
|
|
||||||
module Connection
|
|
||||||
class FayeClientSocket
|
|
||||||
def initialize(env, event_target, stream_event_loop, protocols)
|
|
||||||
@env = env
|
|
||||||
@event_target = event_target
|
|
||||||
@protocols = protocols
|
|
||||||
|
|
||||||
@faye = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def alive?
|
|
||||||
@faye && @faye.ready_state == Faye::WebSocket::API::OPEN
|
|
||||||
end
|
|
||||||
|
|
||||||
def transmit(data)
|
|
||||||
connect
|
|
||||||
@faye.send data
|
|
||||||
end
|
|
||||||
|
|
||||||
def close
|
|
||||||
@faye && @faye.close
|
|
||||||
end
|
|
||||||
|
|
||||||
def protocol
|
|
||||||
@faye && @faye.protocol
|
|
||||||
end
|
|
||||||
|
|
||||||
def rack_response
|
|
||||||
connect
|
|
||||||
@faye.rack_response
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def connect
|
|
||||||
return if @faye
|
|
||||||
@faye = Faye::WebSocket.new(@env, @protocols)
|
|
||||||
|
|
||||||
@faye.on(:open) { |event| @event_target.on_open }
|
|
||||||
@faye.on(:message) { |event| @event_target.on_message(event.data) }
|
|
||||||
@faye.on(:close) { |event| @event_target.on_close(event.reason, event.code) }
|
|
||||||
@faye.on(:error) { |event| @event_target.on_error(event.message) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,44 +0,0 @@
|
||||||
require "thread"
|
|
||||||
|
|
||||||
require "eventmachine"
|
|
||||||
EventMachine.epoll if EventMachine.epoll?
|
|
||||||
EventMachine.kqueue if EventMachine.kqueue?
|
|
||||||
|
|
||||||
module ActionCable
|
|
||||||
module Connection
|
|
||||||
class FayeEventLoop
|
|
||||||
@@mutex = Mutex.new
|
|
||||||
|
|
||||||
def timer(interval, &block)
|
|
||||||
ensure_reactor_running
|
|
||||||
EMTimer.new(::EM::PeriodicTimer.new(interval, &block))
|
|
||||||
end
|
|
||||||
|
|
||||||
def post(task = nil, &block)
|
|
||||||
task ||= block
|
|
||||||
|
|
||||||
ensure_reactor_running
|
|
||||||
::EM.next_tick(&task)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
def ensure_reactor_running
|
|
||||||
return if EventMachine.reactor_running?
|
|
||||||
@@mutex.synchronize do
|
|
||||||
Thread.new { EventMachine.run } unless EventMachine.reactor_running?
|
|
||||||
Thread.pass until EventMachine.reactor_running?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class EMTimer
|
|
||||||
def initialize(inner)
|
|
||||||
@inner = inner
|
|
||||||
end
|
|
||||||
|
|
||||||
def shutdown
|
|
||||||
@inner.cancel
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -4,7 +4,7 @@ module ActionCable
|
||||||
# in a Rails config initializer.
|
# in a Rails config initializer.
|
||||||
class Configuration
|
class Configuration
|
||||||
attr_accessor :logger, :log_tags
|
attr_accessor :logger, :log_tags
|
||||||
attr_accessor :use_faye, :connection_class, :worker_pool_size
|
attr_accessor :connection_class, :worker_pool_size
|
||||||
attr_accessor :disable_request_forgery_protection, :allowed_request_origins
|
attr_accessor :disable_request_forgery_protection, :allowed_request_origins
|
||||||
attr_accessor :cable, :url, :mount_path
|
attr_accessor :cable, :url, :mount_path
|
||||||
|
|
||||||
|
@ -37,19 +37,11 @@ module ActionCable
|
||||||
end
|
end
|
||||||
|
|
||||||
def event_loop_class
|
def event_loop_class
|
||||||
if use_faye
|
ActionCable::Connection::StreamEventLoop
|
||||||
ActionCable::Connection::FayeEventLoop
|
|
||||||
else
|
|
||||||
ActionCable::Connection::StreamEventLoop
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def client_socket_class
|
def client_socket_class
|
||||||
if use_faye
|
ActionCable::Connection::ClientSocket
|
||||||
ActionCable::Connection::FayeClientSocket
|
|
||||||
else
|
|
||||||
ActionCable::Connection::ClientSocket
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,6 @@ class ClientTest < ActionCable::TestCase
|
||||||
server.config.logger = Logger.new(StringIO.new).tap { |l| l.level = Logger::UNKNOWN }
|
server.config.logger = Logger.new(StringIO.new).tap { |l| l.level = Logger::UNKNOWN }
|
||||||
|
|
||||||
server.config.cable = ActiveSupport::HashWithIndifferentAccess.new(adapter: "async")
|
server.config.cable = ActiveSupport::HashWithIndifferentAccess.new(adapter: "async")
|
||||||
server.config.use_faye = ENV["FAYE"].present?
|
|
||||||
|
|
||||||
# and now the "real" setup for our test:
|
# and now the "real" setup for our test:
|
||||||
server.config.disable_request_forgery_protection = true
|
server.config.disable_request_forgery_protection = true
|
||||||
|
|
|
@ -33,8 +33,6 @@ class ActionCable::Connection::ClientSocketTest < ActionCable::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test "delegate socket errors to on_error handler" do
|
test "delegate socket errors to on_error handler" do
|
||||||
skip if ENV["FAYE"].present?
|
|
||||||
|
|
||||||
run_in_eventmachine do
|
run_in_eventmachine do
|
||||||
connection = open_connection
|
connection = open_connection
|
||||||
|
|
||||||
|
@ -49,8 +47,6 @@ class ActionCable::Connection::ClientSocketTest < ActionCable::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test "closes hijacked i/o socket at shutdown" do
|
test "closes hijacked i/o socket at shutdown" do
|
||||||
skip if ENV["FAYE"].present?
|
|
||||||
|
|
||||||
run_in_eventmachine do
|
run_in_eventmachine do
|
||||||
connection = open_connection
|
connection = open_connection
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ class ActionCable::Connection::StreamTest < ActionCable::TestCase
|
||||||
|
|
||||||
[ EOFError, Errno::ECONNRESET ].each do |closed_exception|
|
[ EOFError, Errno::ECONNRESET ].each do |closed_exception|
|
||||||
test "closes socket on #{closed_exception}" do
|
test "closes socket on #{closed_exception}" do
|
||||||
skip if ENV["FAYE"].present?
|
|
||||||
|
|
||||||
run_in_eventmachine do
|
run_in_eventmachine do
|
||||||
connection = open_connection
|
connection = open_connection
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,7 @@ class TestServer
|
||||||
@logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
|
@logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
|
||||||
|
|
||||||
@config = OpenStruct.new(log_tags: [], subscription_adapter: subscription_adapter)
|
@config = OpenStruct.new(log_tags: [], subscription_adapter: subscription_adapter)
|
||||||
@config.use_faye = ENV["FAYE"].present?
|
@config.client_socket_class = ActionCable::Connection::ClientSocket
|
||||||
@config.client_socket_class = if @config.use_faye
|
|
||||||
ActionCable::Connection::FayeClientSocket
|
|
||||||
else
|
|
||||||
ActionCable::Connection::ClientSocket
|
|
||||||
end
|
|
||||||
|
|
||||||
@mutex = Monitor.new
|
@mutex = Monitor.new
|
||||||
end
|
end
|
||||||
|
@ -25,12 +20,8 @@ class TestServer
|
||||||
end
|
end
|
||||||
|
|
||||||
def event_loop
|
def event_loop
|
||||||
@event_loop ||= if @config.use_faye
|
@event_loop ||= ActionCable::Connection::StreamEventLoop.new.tap do |loop|
|
||||||
ActionCable::Connection::FayeEventLoop.new
|
loop.instance_variable_set(:@executor, Concurrent.global_io_executor)
|
||||||
else
|
|
||||||
ActionCable::Connection::StreamEventLoop.new.tap do |loop|
|
|
||||||
loop.instance_variable_set(:@executor, Concurrent.global_io_executor)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ module CommonSubscriptionAdapterTest
|
||||||
def setup
|
def setup
|
||||||
server = ActionCable::Server::Base.new
|
server = ActionCable::Server::Base.new
|
||||||
server.config.cable = cable_config.with_indifferent_access
|
server.config.cable = cable_config.with_indifferent_access
|
||||||
server.config.use_faye = ENV["FAYE"].present?
|
|
||||||
|
|
||||||
adapter_klass = server.config.pubsub_adapter
|
adapter_klass = server.config.pubsub_adapter
|
||||||
|
|
||||||
|
|
|
@ -13,41 +13,7 @@ end
|
||||||
# Require all the stubs and models
|
# Require all the stubs and models
|
||||||
Dir[File.dirname(__FILE__) + "/stubs/*.rb"].each { |file| require file }
|
Dir[File.dirname(__FILE__) + "/stubs/*.rb"].each { |file| require file }
|
||||||
|
|
||||||
if ENV["FAYE"].present?
|
class ActionCable::TestCase < ActiveSupport::TestCase
|
||||||
require "faye/websocket"
|
|
||||||
class << Faye::WebSocket
|
|
||||||
remove_method :ensure_reactor_running
|
|
||||||
|
|
||||||
# We don't want Faye to start the EM reactor in tests because it makes testing much harder.
|
|
||||||
# We want to be able to start and stop EM loop in tests to make things simpler.
|
|
||||||
def ensure_reactor_running
|
|
||||||
# no-op
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module EventMachineConcurrencyHelpers
|
|
||||||
def wait_for_async
|
|
||||||
EM.run_deferred_callbacks
|
|
||||||
end
|
|
||||||
|
|
||||||
def run_in_eventmachine
|
|
||||||
failure = nil
|
|
||||||
EM.run do
|
|
||||||
begin
|
|
||||||
yield
|
|
||||||
rescue => ex
|
|
||||||
failure = ex
|
|
||||||
ensure
|
|
||||||
wait_for_async
|
|
||||||
EM.stop if EM.reactor_running?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
raise failure if failure
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module ConcurrentRubyConcurrencyHelpers
|
|
||||||
def wait_for_async
|
def wait_for_async
|
||||||
wait_for_executor Concurrent.global_io_executor
|
wait_for_executor Concurrent.global_io_executor
|
||||||
end
|
end
|
||||||
|
@ -56,14 +22,6 @@ module ConcurrentRubyConcurrencyHelpers
|
||||||
yield
|
yield
|
||||||
wait_for_async
|
wait_for_async
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
class ActionCable::TestCase < ActiveSupport::TestCase
|
|
||||||
if ENV["FAYE"].present?
|
|
||||||
include EventMachineConcurrencyHelpers
|
|
||||||
else
|
|
||||||
include ConcurrentRubyConcurrencyHelpers
|
|
||||||
end
|
|
||||||
|
|
||||||
def wait_for_executor(executor)
|
def wait_for_executor(executor)
|
||||||
# do not wait forever, wait 2s
|
# do not wait forever, wait 2s
|
||||||
|
|
Loading…
Reference in New Issue