Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea2348682e | |||
| 684e940266 | |||
| 5bd67aedb5 | |||
| 456b76ec71 | |||
| 04a68797f0 | |||
| 49fb05e1f2 | |||
| e76c9e736c | |||
| 9777d1acfe | |||
| 253549d2e7 | |||
| fee61a8d65 | |||
| 24f800c134 | |||
| 8e181f9801 | |||
| 47d793757e | |||
| 8f2aca6d5c | |||
| 75578ffdd2 | |||
| 86ae4baa3d | |||
| e84e20bba4 | |||
| 4fdafd8877 | |||
| 01b84b338c | |||
| fa4cd75dba |
+1
-2
@@ -2,10 +2,9 @@
|
||||
.gitignore
|
||||
.gitmodules
|
||||
.npmignore
|
||||
.redcar
|
||||
.travis.yml
|
||||
dump.rdb
|
||||
Rakefile
|
||||
Makefile
|
||||
node_modules
|
||||
spec
|
||||
vendor
|
||||
|
||||
+8
-3
@@ -1,12 +1,17 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "0.6"
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
|
||||
services:
|
||||
- redis-server
|
||||
|
||||
before_install:
|
||||
- test $TRAVIS_NODE_VERSION = '0.8' && npm install -g npm@1.2.8000 || true
|
||||
|
||||
before_script:
|
||||
- rake prepare
|
||||
- make
|
||||
|
||||
env: TRAVIS=1
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
### 0.2.0 / 2013-10-01
|
||||
|
||||
* Trigger the `close` event as required by Faye 1.0
|
||||
|
||||
|
||||
### 0.1.3 / 2013-05-11
|
||||
|
||||
* Fix a bug due to a misuse of `this`
|
||||
|
||||
|
||||
### 0.1.2 / 2013-04-28
|
||||
|
||||
* Improve garbage collection to avoid leaking Redis memory
|
||||
|
||||
|
||||
### 0.1.1 / 2012-07-15
|
||||
|
||||
* Fix an implicit global variable leak (missing semicolon)
|
||||
|
||||
|
||||
### 0.1.0 / 2012-02-26
|
||||
|
||||
* Initial release: Redis backend for Faye 0.8
|
||||
@@ -1,14 +0,0 @@
|
||||
=== 0.1.2 / 2013-04-28
|
||||
|
||||
* Improve garbage collection to avoid leaking Redis memory
|
||||
|
||||
|
||||
=== 0.1.1 / 2012-07-15
|
||||
|
||||
* Fix an implicit global variable leak (missing semicolon)
|
||||
|
||||
|
||||
=== 0.1.0 / 2012-02-26
|
||||
|
||||
* Initial release: Redis backend for Faye 0.8
|
||||
|
||||
@@ -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).
|
||||
@@ -0,0 +1,5 @@
|
||||
prepare:
|
||||
git submodule update --init --recursive
|
||||
cd vendor/faye && npm install
|
||||
cd vendor/faye && ./node_modules/.bin/wake
|
||||
npm install
|
||||
+15
-16
@@ -1,9 +1,9 @@
|
||||
# faye-redis [](http://travis-ci.org/faye/faye-redis-node)
|
||||
# faye-redis [](http://travis-ci.org/faye/faye-redis-node)
|
||||
|
||||
This plugin provides a Redis-based backend for the [Faye](http://faye.jcoglan.com)
|
||||
messaging server. It allows a single Faye service to be distributed across many
|
||||
front-end web servers by storing state and routing messages through a
|
||||
[Redis](http://redis.io) database server.
|
||||
This plugin provides a Redis-based backend for the
|
||||
[Faye](http://faye.jcoglan.com) messaging server. It allows a single Faye
|
||||
service to be distributed across many front-end web servers by storing state and
|
||||
routing messages through a [Redis](http://redis.io) database server.
|
||||
|
||||
|
||||
## Usage
|
||||
@@ -33,25 +33,25 @@ server.listen(8000);
|
||||
|
||||
The full list of settings is as follows.
|
||||
|
||||
* <b><tt>host</tt></b> - hostname of your Redis instance
|
||||
* <b><tt>port</tt></b> - port number, default is `6379`
|
||||
* <b><tt>password</tt></b> - password, if `requirepass` is set
|
||||
* <b><tt>database</tt></b> - number of database to use, default is `0`
|
||||
* <b><tt>namespace</tt></b> - prefix applied to all keys, default is `''`
|
||||
* <b><tt>socket</tt></b> - path to Unix socket if `unixsocket` is set
|
||||
* <b>`host`</b> - hostname of your Redis instance
|
||||
* <b>`port`</b> - port number, default is `6379`
|
||||
* <b>`password`</b> - password, if `requirepass` is set
|
||||
* <b>`database`</b> - number of database to use, default is `0`
|
||||
* <b>`namespace`</b> - prefix applied to all keys, default is `''`
|
||||
* <b>`socket`</b> - path to Unix socket if `unixsocket` is set
|
||||
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011-2012 James Coglan
|
||||
Copyright (c) 2011-2013 James Coglan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the 'Software'), to deal in
|
||||
the Software without restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
Software, and to permit persons to whom the Software is furnished to do so,
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
@@ -63,4 +63,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,15 +0,0 @@
|
||||
require 'fileutils'
|
||||
|
||||
task :prepare do
|
||||
`git submodule update --init --recursive`
|
||||
`gem install jake`
|
||||
FileUtils.cd 'vendor/faye' do
|
||||
`bundle install`
|
||||
`npm install`
|
||||
`jake`
|
||||
end
|
||||
`npm install`
|
||||
end
|
||||
|
||||
task :default => :prepare
|
||||
|
||||
+27
-20
@@ -27,10 +27,15 @@ var Engine = function(server, options) {
|
||||
this._redis.select(db);
|
||||
this._subscriber.select(db);
|
||||
|
||||
this._messageChannel = this._ns + '/notifications/messages';
|
||||
this._closeChannel = this._ns + '/notifications/close';
|
||||
|
||||
var self = this;
|
||||
this._subscriber.subscribe(this._ns + '/notifications');
|
||||
this._subscriber.subscribe(this._messageChannel);
|
||||
this._subscriber.subscribe(this._closeChannel);
|
||||
this._subscriber.on('message', function(topic, message) {
|
||||
self.emptyQueue(message);
|
||||
if (topic === self._messageChannel) self.emptyQueue(message);
|
||||
if (topic === self._closeChannel) self._server.trigger('close', message);
|
||||
});
|
||||
|
||||
this._gc = setInterval(function() { self.gc() }, gc * 1000);
|
||||
@@ -76,27 +81,29 @@ Engine.prototype = {
|
||||
destroyClient: function(clientId, callback, context) {
|
||||
var self = this;
|
||||
|
||||
this._redis.zadd(this._ns + '/clients', 0, clientId, function() {
|
||||
self._redis.smembers(self._ns + '/clients/' + clientId + '/channels', function(error, channels) {
|
||||
var n = channels.length, i = 0;
|
||||
if (i === n) return self._afterSubscriptionsRemoved(clientId, callback, context);
|
||||
this._redis.smembers(this._ns + '/clients/' + clientId + '/channels', function(error, channels) {
|
||||
var multi = self._redis.multi();
|
||||
|
||||
channels.forEach(function(channel) {
|
||||
self.unsubscribe(clientId, channel, function() {
|
||||
i += 1;
|
||||
if (i === n) self._afterSubscriptionsRemoved(clientId, callback, context);
|
||||
});
|
||||
});
|
||||
multi.zadd(self._ns + '/clients', 0, clientId);
|
||||
|
||||
channels.forEach(function(channel) {
|
||||
multi.srem(self._ns + '/clients/' + clientId + '/channels', channel);
|
||||
multi.srem(self._ns + '/channels' + channel, clientId);
|
||||
});
|
||||
});
|
||||
},
|
||||
multi.del(self._ns + '/clients/' + clientId + '/messages');
|
||||
multi.zrem(self._ns + '/clients', clientId);
|
||||
multi.publish(self._closeChannel, clientId);
|
||||
|
||||
multi.exec(function(error, results) {
|
||||
channels.forEach(function(channel, i) {
|
||||
if (results[2 * i + 1] !== 1) return;
|
||||
self._server.trigger('unsubscribe', clientId, channel);
|
||||
self._server.debug('Unsubscribed client ? from channel ?', clientId, channel);
|
||||
});
|
||||
|
||||
_afterSubscriptionsRemoved: function(clientId, callback, context) {
|
||||
var self = this;
|
||||
this._redis.del(this._ns + '/clients/' + clientId + '/messages', function() {
|
||||
self._redis.zrem(self._ns + '/clients', clientId, function() {
|
||||
self._server.debug('Destroyed client ?', clientId);
|
||||
self._server.trigger('disconnect', clientId);
|
||||
|
||||
if (callback) callback.call(context);
|
||||
});
|
||||
});
|
||||
@@ -147,10 +154,10 @@ Engine.prototype = {
|
||||
|
||||
self._server.debug('Queueing for client ?: ?', clientId, message);
|
||||
self._redis.rpush(queue, jsonMessage);
|
||||
self._redis.publish(self._ns + '/notifications', clientId);
|
||||
self._redis.publish(self._messageChannel, clientId);
|
||||
|
||||
self.clientExists(clientId, function(exists) {
|
||||
if (!exists) this._redis.del(queue);
|
||||
if (!exists) self._redis.del(queue);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
+6
-12
@@ -3,25 +3,19 @@
|
||||
, "homepage" : "http://github.com/faye/faye-redis-node"
|
||||
, "author" : "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)"
|
||||
, "keywords" : ["pubsub", "bayeux"]
|
||||
, "license" : "MIT"
|
||||
|
||||
, "version" : "0.1.2"
|
||||
, "version" : "0.2.0"
|
||||
, "engines" : {"node": ">=0.4.0"}
|
||||
, "main" : "./faye-redis"
|
||||
, "dependencies" : {"redis": ""}
|
||||
, "devDependencies" : {"jsclass": ""}
|
||||
, "devDependencies" : {"jstest": ""}
|
||||
|
||||
, "scripts" : {"test": "node spec/runner.js"}
|
||||
|
||||
, "bugs" : "http://github.com/faye/faye-redis-node/issues"
|
||||
|
||||
, "licenses" : [ { "type" : "MIT"
|
||||
, "url" : "http://www.opensource.org/licenses/mit-license.php"
|
||||
}
|
||||
]
|
||||
|
||||
, "repositories" : [ { "type" : "git"
|
||||
, "url" : "git://github.com/faye/faye-redis-node.git"
|
||||
}
|
||||
]
|
||||
, "repository" : { "type" : "git"
|
||||
, "url" : "git://github.com/faye/faye-redis-node.git"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
var RedisEngine = require('../faye-redis')
|
||||
|
||||
JS.ENV.FayeRedisSpec = JS.Test.describe("Redis engine", function() { with(this) {
|
||||
JS.Test.describe("Redis engine", function() { with(this) {
|
||||
before(function() {
|
||||
var pw = process.env.TRAVIS ? undefined : "foobared"
|
||||
this.engineOpts = {type: RedisEngine, password: pw, namespace: new Date().getTime().toString()}
|
||||
})
|
||||
|
||||
after(function(resume) { with(this) {
|
||||
sync(function() {
|
||||
engine.disconnect()
|
||||
var redis = require('redis').createClient(6379, 'localhost', {no_ready_check: true})
|
||||
redis.auth(engineOpts.password)
|
||||
redis.flushall(function() {
|
||||
redis.end()
|
||||
resume()
|
||||
})
|
||||
disconnect_engine()
|
||||
var redis = require('redis').createClient(6379, 'localhost', {no_ready_check: true})
|
||||
redis.auth(engineOpts.password)
|
||||
redis.flushall(function() {
|
||||
redis.end()
|
||||
resume()
|
||||
})
|
||||
}})
|
||||
|
||||
|
||||
@@ -39,4 +39,3 @@ list-max-ziplist-value 64
|
||||
set-max-intset-entries 512
|
||||
|
||||
activerehashing yes
|
||||
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
require('jsclass')
|
||||
JS.require('JS.Range', 'JS.Test')
|
||||
JS = require('jstest')
|
||||
|
||||
Faye = require('../vendor/faye/build/node/faye-node')
|
||||
require('../vendor/faye/spec/javascript/engine_spec')
|
||||
|
||||
Vendored
+1
-1
Submodule vendor/faye updated: c7fac489b1...aab4127591
Reference in New Issue
Block a user