This ensures work is done more evenly across all queues. The normal RoundRobin reserver always slightly favors the first queue in the list since all workers will start at the same spot everytime they get restarted.
remove request for non-existant image
Previously, it returned a cached LuaScript object that was tied to a particular redis connection object, but it could be a different redis connection object from the one the client is using. That's because we were caching them based on the redis connection URL, since we don't want to reload the scripts into the same server multiple times. However, that caused subtle problems for watch/multi/exec blocks: calling a script could, in some situations, no longer be a no-op for an aborted multi block (e.g. due to a watched key changing). That's because the semantics of a multi block are tied to one redis connection, but the script could be executed by a different redis connection if the cached LuaScript object was using a different redis connection. The solution here is to change the cache so that it caches the SHAs and always constructs a new LuaScript object as needed, so that the redis connection is always the correct one.
It's unnecessary (and slows things down) to load the same script into the same redis server multiple times in the same process.
"LuaScript" is a better name for this class, as it represents a specific lua script, and not the lua language as a whole. While I was at it, I moved the USING_LEGACY_REDIS_VERSION conditional out of the method and into the class body -- might as well evaulate that branch once at load time rather than once per script call.
It's useful in some specs I'm writing in our app to have access to this.
Fix #74 using the "bandaid" solution
The Qless::Worker does not need a reference to a client. It restrict flexibility by coupling it to one client like this. While it does not normally make sense to do so, we have a case where would like a single worker to pull jobs from queues on multiple qless servers, which works just fine because the queue objects themselves know what client to talk to.
Make the server client instance rather than class state.
Kernel works fine when the constant is defined, but when it is undefined, it leads to a confusing error: `undefined constant Kernel::MyJob` ...rather than: `undefined constant MyJob`
Note that this exposed an rspec-mocks bug that I plan to tackle soon: rspec/rspec-mocks#217
We're going to be sharding our qless usage soon and having multiple qless redis servers. We would like to have on web UI per qless redis server, and each needs to be connected to a different qless redis server.
Avoid busy loop when worker is paused.
Exceptions are better than `false` values.