portunus_keepalive (portunus v0.14.0)
View SourceThis module implements automatic background lease renewal for a holder that is an Erlang process.
It is linked to the caller (usually the resource holder) and traps exits.
If the resource holder process dies, the renewer stops. Owners that can be restarted should set up the renewer in their init function.
This module can be used directly, but is usually set up through
portunus:grant_lease/3 with the auto_renew option, or
portunus:lock/3.
LeaseId is renewed every max(TTL/3, 1000) milliseconds, and the
minimum supported TTL is 2000 ms, allowing for at least two renewal
attempts per TTL interval.
A lease renewal attempt can fail if the portunus Ra machine does not
have an online quorum.
The renewer retries until the lease expires.
For environments where hundreds or thousands of leases on one node are to be expected,
prefer portunus_batch_keepalive which renews multiple leases in
one Ra command per round.
portunus_election uses it.
Summary
Functions
-spec start_link(portunus:name(), portunus:lease_id(), pos_integer()) -> {ok, pid()}.
-spec stop(pid()) -> ok.