lusnoc

0
7 лет назад
7 лет назад
7 лет назад
7 лет назад
7 лет назад
4 года назад
7 лет назад
4 года назад
3 года назад
7 лет назад
README.md

Lusnoc

Gem Version Gem YARD

Coverage Quality Outdated Vulnerabilities

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

Lusnoc::Mutex
, giving it the key you want to use as the "lock":

TTL will be used in session creation on

#synchronize
:

If mutex cannot be acquired within given timeout

Lusnoc::TimeoutError
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:

Mirrors