12 Commits

Author SHA1 Message Date
James Coglan 3cc18f07ee Extract the connection-creating mechanics into an object that the user can override via the options. 2017-01-28 23:16:27 +00:00
James Coglan 5d2c20534b Update the Faye submodule to 1.2.4. 2017-01-28 22:57:21 +00:00
James Coglan a0b87ae6a0 Use 0.0.0.0 rather than localhost since EventMachine on macOS struggles with the latter. 2017-01-28 22:57:10 +00:00
James Coglan 0eefa4fbf2 Update the Travis config with the latest Ruby releases. 2017-01-28 22:56:38 +00:00
James Coglan 392aac9ea1 Remove some trailing blank lines. 2017-01-28 22:55:53 +00:00
James Coglan f1a11503ea Create CODE_OF_CONDUCT.md 2015-11-08 12:18:52 +00:00
James Coglan 376ac9f022 Update Travis config. 2014-12-23 00:08:11 +00:00
James Coglan 031cbc6dd3 Bump Faye to 1.1.0. 2014-12-23 00:07:13 +00:00
James Coglan 54847de3cd Oh yeah, you gotta tell Travis you need redis-server running. 2014-09-07 22:03:23 +01:00
James Coglan da99aa13bd Test on some more recent Rubies: 2.1 and rbx-2. 2014-09-07 21:56:35 +01:00
James Coglan c10b0743e4 Bump faye to current master. 2014-09-07 21:54:47 +01:00
James Coglan 47aa08b02a Use the SVG build status icon from Travis. 2014-09-07 21:05:35 +01:00
11 changed files with 58 additions and 31 deletions
+9 -2
View File
@@ -1,10 +1,18 @@
sudo: false
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.10
- 2.2.6
- 2.3.3
- 2.4.0
- jruby-19mode
- rbx-19mode
- jruby-9
services:
- redis-server
before_script:
- git submodule update --init --recursive
@@ -12,4 +20,3 @@ before_script:
script: bundle exec rspec -c spec/
env: TRAVIS=1
+4
View File
@@ -0,0 +1,4 @@
# Code of Conduct
All projects under the [Faye](https://github.com/faye) umbrella are covered by
the [Code of Conduct](https://github.com/faye/code-of-conduct).
+1 -1
View File
@@ -1,2 +1,2 @@
source "https://rubygems.org/"
source 'https://rubygems.org/'
gemspec
+1 -2
View File
@@ -1,4 +1,4 @@
# Faye::Redis [![Build Status](https://travis-ci.org/faye/faye-redis-ruby.png)](https://travis-ci.org/faye/faye-redis-ruby)
# Faye::Redis [![Build Status](https://travis-ci.org/faye/faye-redis-ruby.svg)](https://travis-ci.org/faye/faye-redis-ruby)
This plugin provides a Redis-based backend for the
[Faye](http://faye.jcoglan.com) messaging server. It allows a single Faye
@@ -58,4 +58,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+1
View File
@@ -18,5 +18,6 @@ Gem::Specification.new do |s|
s.add_dependency 'multi_json', '>= 1.0.0'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rspec-eventmachine'
s.add_development_dependency 'websocket-driver'
end
+9 -20
View File
@@ -1,14 +1,13 @@
require 'em-hiredis'
require 'multi_json'
require File.expand_path('../redis_factory', __FILE__)
module Faye
class Redis
DEFAULT_HOST = 'localhost'
DEFAULT_PORT = 6379
DEFAULT_DATABASE = 0
DEFAULT_GC = 60
LOCK_TIMEOUT = 120
DEFAULT_GC = 60
LOCK_TIMEOUT = 120
def self.create(server, options)
new(server, options)
@@ -17,27 +16,18 @@ module Faye
def initialize(server, options)
@server = server
@options = options
@factory = options[:factory] || RedisFactory.new(options)
init
end
def init
return if @redis
return if @redis or !EventMachine.reactor_running?
uri = @options[:uri] || nil
host = @options[:host] || DEFAULT_HOST
port = @options[:port] || DEFAULT_PORT
db = @options[:database] || DEFAULT_DATABASE
auth = @options[:password] || nil
gc = @options[:gc] || DEFAULT_GC
@ns = @options[:namespace] || ''
socket = @options[:socket] || nil
@redis = @factory.call
if uri
@redis = EventMachine::Hiredis.connect(uri)
elsif socket
@redis = EventMachine::Hiredis::Client.new(socket, nil, auth, db).connect
else
@redis = EventMachine::Hiredis::Client.new(host, port, auth, db).connect
end
@subscriber = @redis.pubsub
@message_channel = @ns + '/notifications/messages'
@@ -235,4 +225,3 @@ module Faye
end
end
+30
View File
@@ -0,0 +1,30 @@
module Faye
class RedisFactory
DEFAULT_HOST = '0.0.0.0'
DEFAULT_PORT = 6379
DEFAULT_DATABASE = 0
def initialize(options)
@options = options
end
def call
uri = @options[:uri] || nil
socket = @options[:socket] || nil
host = @options[:host] || DEFAULT_HOST
port = @options[:port] || DEFAULT_PORT
auth = @options[:password] || nil
db = @options[:database] || DEFAULT_DATABASE
if uri
EventMachine::Hiredis.connect(uri)
elsif socket
EventMachine::Hiredis::Client.new(socket, nil, auth, db).connect
else
EventMachine::Hiredis::Client.new(host, port, auth, db).connect
end
end
end
end
+2 -3
View File
@@ -7,8 +7,8 @@ describe Faye::Redis do
end
after do
engine.disconnect
redis = EM::Hiredis::Client.connect('localhost', 6379)
disconnect_engine
redis = EM::Hiredis::Client.connect('0.0.0.0', 6379)
redis.auth(engine_opts[:password])
redis.flushall
end
@@ -23,4 +23,3 @@ describe Faye::Redis do
it_should_behave_like "faye engine"
end
end
-1
View File
@@ -39,4 +39,3 @@ list-max-ziplist-value 64
set-max-intset-entries 512
activerehashing yes
-1
View File
@@ -5,4 +5,3 @@ require File.expand_path('../../vendor/faye/spec/ruby/engine_examples', __FILE__
class << Faye
attr_accessor :logger
end
Vendored
+1 -1