mranney/node_redis — pull request #310 by othiym23 (2012-10-15 07:39:28+00:00)
Title: add support for 0.8+ 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 active.
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.

Number 3 looks a little weird to my eye, so I have a question open with @isaacs as to whether it's how the error should be put into the domain; it feels like I'm relying on an implementation detail. Regardless, the test passes, and the test code is a bog-standard use of domains.

I haven't done any benchmarking, but the overhead imposed by the change should be negligible when domains aren't being used, and small when they are.