portunus_batch_keepalive (portunus v0.14.0)
View SourceRenews multiple leases in a single renewal round, for nodes with a lot of processes that use automatic lease renewal.
portunus_keepalive gives every holder its own renewer, so a node with N
leases sends N renewal calls every TTL/3, each a leader round trip with a
quorum heartbeat.
This module is one registered process per node that holders attach
leases to. Leases sharing a {ClusterName, TTL} pair renew together in
a single portunus:renew_leases/3 call, so the rate is per node, not
per lease.
Resource owner processes monitor it and re-attach if it restarts. A lease survives the restart as long as the owner re-attaches within a TTL of the last renewal.
Summary
Functions
Attach LeaseId for batched renewal, with the caller as its lock owner.
Pass the TTL the lease was granted with. The owner process should monitor
this server (registered as portunus_batch_keepalive) and re-attach on
'DOWN'.
Stop renewing LeaseId. Idempotent.
The attached leases per {ClusterName, TTL} group. For introspection and tests.
Types
-type group_key() :: {portunus:cluster_name(), portunus:ttl()}.
Functions
-spec attach(portunus:cluster_name(), portunus:lease_id(), portunus:ttl()) -> ok.
Attach LeaseId for batched renewal, with the caller as its lock owner.
Pass the TTL the lease was granted with. The owner process should monitor
this server (registered as portunus_batch_keepalive) and re-attach on
'DOWN'.
-spec detach(portunus:cluster_name(), portunus:lease_id()) -> ok.
Stop renewing LeaseId. Idempotent.
-spec overview() -> #{group_key() => [portunus:lease_id()]}.
The attached leases per {ClusterName, TTL} group. For introspection and tests.