portunus_affinity behaviour (portunus v0.8.0)
View SourceAn affinity strategy gives each portunus node (cluster member) a score
for a key, and portunus_machine succession promotes the highest-scoring
contender. Ties are broken in favor of the node that joined the succession
queue first.
Two strategies are supported:
deterministic: a pure function of the key and the cluster members, so every node computes the same ranking. Built-in variants:fifo,pinned,preferred,hashdynamic: a node scores itself from local dynamically calculated state such as metrics (load, resource consumption, etc). Built-in variants:metric,random
Affinity strategies are passed around as a spec() that carries a short
name (fifo, pinned, random, and so on). To use a custom module,
pass a {Module, Args} tuple where Module implements the kind/0
and score/3 callbacks.
Summary
Functions
This node's score for Key, given the current cluster Members.