portunus_keepalive (portunus v0.8.0)

View Source

This 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.

Summary

Functions

handle_call(Req, From, State)

handle_cast(Msg, State)

handle_info/2

init/1

start_link(Name, LeaseId, TtlMs)

-spec start_link(portunus:name(), portunus:lease_id(), pos_integer()) -> {ok, pid()}.

stop(Pid)

-spec stop(pid()) -> ok.

terminate(Reason, State)