I wanted to reserve after the beanstalkd connection has connected successfully - however this was surprisingly hard to achieve (unless I've just missed something)
Explicitly, this is what I wanted
The EMJack::Connection object is a deferrable, however you can't do
# Doesn't work
conn = EMJack::Connection.new
# reserve on tube
This doesn't work because EMJack::Connection (which is a deferrable) fails on the first unsuccessful connection attempt. The Connection#disconnected method calls set_deferred_status(nil) which will clear all callbacks.
My conclusion is that the EMJack::Connection deferrable is used heavily for internal callbacks and thus it's behaviour can't be changed. Therefore an on_connect callback is required.
It's also necessary to have a connected? boolean: in the case that code needs to reserve dynamically, it needs to know whether to just reserve of reserve in an on_connect callback.
Code is attached but not tested - if you're happy with this addition then I'll add the tests for it :)
Add on_connect callback
Add Connection#connected? method
This looks good to me. I've merged this part in, if you have time to write some tests please send them my way.