All Redis deps are now optional, Postgres --> PostgreSQL adapter

This commit is contained in:
Jon Moss 2016-01-15 19:03:05 -05:00
parent 75489642c8
commit 6aeaed4c1a
7 changed files with 17 additions and 15 deletions

View File

@ -32,9 +32,7 @@ PATH
actioncable (5.0.0.beta1)
actionpack (= 5.0.0.beta1)
coffee-rails (~> 4.1.0)
em-hiredis (~> 0.3.0)
faye-websocket (~> 0.10.0)
redis (~> 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0.beta1)
actionpack (= 5.0.0.beta1)
@ -140,9 +138,6 @@ GEM
delayed_job_active_record (4.1.0)
activerecord (>= 3.0, < 5)
delayed_job (>= 3.0, < 5)
em-hiredis (0.3.0)
eventmachine (~> 1.0)
hiredis (~> 0.5.0)
erubis (2.7.0)
eventmachine (1.0.9.1)
execjs (2.6.0)
@ -154,7 +149,6 @@ GEM
ffi (1.9.10-x86-mingw32)
globalid (0.3.6)
activesupport (>= 4.1.0)
hiredis (0.5.2)
hitimes (1.2.3)
hitimes (1.2.3-x86-mingw32)
i18n (0.7.0)

View File

@ -23,10 +23,10 @@ Gem::Specification.new do |s|
s.add_dependency 'coffee-rails', '~> 4.1.0'
s.add_dependency 'faye-websocket', '~> 0.10.0'
s.add_dependency 'websocket-driver', '~> 0.6.1'
s.add_dependency 'em-hiredis', '~> 0.3.0'
s.add_dependency 'redis', '~> 3.0'
s.add_development_dependency 'puma'
s.add_development_dependency 'em-hiredis', '~> 0.3.0'
s.add_development_dependency 'mocha'
s.add_development_dependency 'pg'
s.add_development_dependency 'puma'
s.add_development_dependency 'redis', '~> 3.0'
end

View File

@ -1,7 +1,7 @@
module ActionCable
module StorageAdapter
autoload :Base, 'action_cable/storage_adapter/base'
autoload :Postgres, 'action_cable/storage_adapter/postgres'
autoload :PostgreSQL, 'action_cable/storage_adapter/postgresql'
autoload :Redis, 'action_cable/storage_adapter/redis'
end
end

View File

@ -1,8 +1,14 @@
require 'thread'
begin
require 'pg'
rescue Gem::LoadError => e
raise Gem::LoadError, "You are trying to use the PostgreSQL ActionCable adapter, but do not have the proper gems installed. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActionCable)."
end
module ActionCable
module StorageAdapter
class Postgres < Base
class PostgreSQL < Base
# The storage instance used for broadcasting. Not intended for direct user use.
def broadcast(channel, payload)
with_connection do |pg_conn|

View File

@ -1,5 +1,9 @@
require 'em-hiredis'
require 'redis'
begin
require 'em-hiredis'
require 'redis'
rescue Gem::LoadError => e
raise Gem::LoadError, "You are trying to use the Redis ActionCable adapter, but do not have the proper gems installed. Add `gem 'em-hiredis'` and `gem 'redis'` to your Gemfile (and ensure its version is at the minimum required by ActionCable)."
end
module ActionCable
module StorageAdapter

View File

@ -62,7 +62,6 @@ class ActionCable::Channel::StreamTest < ActionCable::TestCase
test "subscription confirmation should only be sent out once" do
EM.run do
connection = TestConnection.new
connection.stubs(:pubsub).returns EM::Hiredis.connect.pubsub
channel = ChatChannel.new connection, "test_channel"
channel.send_confirmation

View File

@ -5,7 +5,6 @@ require 'active_support/testing/autorun'
require 'puma'
require 'em-hiredis'
require 'mocha/setup'