Added safe relock function 

Required a changed in the lock function to return the lock ID instead of the unlock callback.
Hi Geoff,

No problem, thanks for coming back to me :)

I am using a cursor to tail the MongoDB oplog collection. I persist the
position of this cursor so a process fails, I can restore from the saved
position in another process (so nothing is lost, I am ok with msg
duplication in Kafka).

I want to use redis lock only to identify the master process.

I will update the lib based on your feedback and will reissue the merge
request.

Best,
Maciej

On Mon, Nov 3, 2014 at 5:29 PM, Geoff Wagstaff <notifications@github.com>
wrote:

> In lib/warlock.js:
>
> >
> > -        return cb(err, unlock);
> > +        return cb(err, id);
>
> Apologies for the delay Maciej, and thanks for the details on your use
> case.
>
> How long is your delay? Not sure exactly how you are obtaining ops from
> MongoDB but you might miss some during this failover delay window?
>
> Is there a way to use the failover built into MongoDB itself to achieve
> similar?
>
> Anyway, I think a method to extend the TTL of an existing lock is useful.
> We can call it touch(). Extra param of lock ID is preferable to changing
> the type of first param, so I'd go with that.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/TheDeveloper/warlock/pull/4/files#r19748988>.
>