openresty/lua-resty-redis — pull request #49 by pintsized (2014-09-16 11:39:14+00:00)
Title: Utility functions for working with Sentinel and wrapping common connection patterns

Sentinel is a special execution mode of Redis offering a service discovery API to dynamically select a master or slave. This pull request contains simple functions for using this as well as adds the "sentinel" command to the default command set.

The Connector functions wrap the Sentinel functions, making it easy to reliably connect to a Redis host with a table of config parameters. These are equally useful for plain connections (i.e. non Sentinel) or connecting to a dynamically discovered master (or slave), in a uniform manner, cleaning up the amount of repeated connection error checking in user code, which introduces potential for unchecked cases etc.

I've written tests for the main Connector functions, but Sentinel remains tricky, since it depends on a working and configured Sentinel quorum to test anything meaningfully. I wondered about creating some kind of dummy stub service but wasn't sure how that might fit into the existing test framework?

Thoughts?