1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Added direct support for domains.

There are three pieces to this support, all of them small, and none of
them with large overhead:

  1. When sending a command, ensure that any callback is bound to the
     current domain, if one is present.
  2. Also add the RedisClient to the current domain so that error
     events bubble properly.
  3. In try_callback, when a domain is in play, instead of throwing
     on the next tick, emit the error on the domain. The parser can
     still finish processing the response and the error ends up in
     the correct place.
This commit is contained in:
Forrest L Norvell
2012-10-15 00:21:55 -07:00
committed by Forrest L Norvell
parent 8e4c9557d0
commit 0b6870be5c
2 changed files with 38 additions and 3 deletions

24
test.js
View File

@@ -1950,6 +1950,30 @@ tests.SLOWLOG = function () {
});
}
tests.DOMAIN = function () {
var name = "DOMAIN";
var domain;
try {
domain = require('domain').create();
} catch (err) {
console.log("Skipping " + name + " because this version of node doesn't have domains.");
next(name);
}
if (domain) {
domain.run(function () {
client.set('domain', 'value', function (err, res) {
assert.ok(process.domain);
var notFound = res.not.existing.thing; // ohhh nooooo
});
});
// this is the expected and desired behavior
domain.on('error', function (err) { next(name); });
}
};
// TODO - need a better way to test auth, maybe auto-config a local Redis server or something.
// Yes, this is the real password. Please be nice, thanks.
tests.auth = function () {