lusnoc
Описание
[MIRROR] Lusnoc is reliable gem to deal with consul locks and sessions
Языки
- Ruby96,8%
- Dockerfile3,2%
Lusnoc
Lusnoc is reliable gem to deal with Consul. It is designed to be simple and work without dark background magic. It is inspired by consul-mutex(which has hard background magic).
Article about gem: https://blog.rnds.pro/lusnoc (in russian)
FAQ
What's Lusnoc for?
Lusnoc allows you to interact with Consul to provide distributed locks(mutex) to your application.
What's the difference between lusnoc and consul-mutex or diplomat
- consul-mutex starts background thread and the block of code that you pass to #synchronize runs on a separate thread, and can be killed without warning if the mutex determines that it no longer holds the lock.
- diplomat provides the basic session/locks functionality but no automated control over it
How Lusnoc deal with sessions/mutexes?
- Lusnoc ensures session creation/destruction upon block execution
- Lusnoc uses only sessions with TTL to protect you system from stale sessions/locks
- Lusnoc enforces you to manualy renew session(through callback or explicit check) but provide background session checker
- Lusnoc tries to carefuly handle timeouts and expiration using Consul blocking queries
Usage
Simply instantiate a new , giving it the key you want to use
as the "lock":
TTL will be used in session creation on :
If mutex cannot be acquired within given timeout is raised.
By default, the "value" of the lock resource will be the hostname of the
machine that it's running on (so you know who has the lock). If, for some
reason, you'd like to set the value to something else, you can do that, too:
Session invalidation/renewal handled through mutex instance:
You can use only Session:
Typical usage scenario:
Installation
It's a gem:
There's also the wonders of the Gemfile: