nfarring/redisrpc — pull request #8 by yaauie (2012-04-24 20:56:03+00:00)
Title: Dev/ruby rewrite

*NOTE: depends on the results of #7 being pulled in*

I'm having to commit to this in fits and starts, mostly because I cannot commit to GPLv3 while on company time (we love open-source, it's just too restrictive a license). Instead of submitting 5 or so pull requests to get to this point, I did a on-my-lunch quick rewrite using your code as a template. If you'd like I'll gladly split this up into smaller chunks, but it might take a week or so. The following is a summary of what was changed functionally:

- Clean up memory leak: expire the `respons_queue` in one second. If client is waiting with a `blpop`, it will have already received the value; if client has timed out, it is not waiting and no client will receive this message until a collision of response_queues occurs.
- Clean up necessitated double-work: if client times out before server picks up (perhaps it is busy serving another client and isn't `blpop`-ing), remove the task from queue as we exit.
- Add a configurable timeout to the server, either as an arg or as a global. We were hitting instances in JRuby where Redis#blpop will stall out and block forever, despite items being put in queue; this ensures that we can configure around the issue.
- use `send` instead of routing everything through `method_missing`; I still provide the latter, but it feels a bit too "magic" to use it. This is a personal style thing, but it falls inline with most of the ruby community.
- route `respond_to?` to the remote object
- include backtrace with the remote exception, and explicitly pass the exception.to_s since not everything can pass through MultiJson.dump (Or JSON.encode) safely