elector_candidate_cache (elector v0.3.3)

View Source

Candidate cache manager - maintains a distributed cache of candidate nodes.

This module implements a smart caching system that: - Monitors node join/leave events - Maintains local cache of candidate nodes - Broadcasts candidate status on startup and node events - Eliminates need for remote calls during elections

Summary

Functions

Returns the current list of candidate nodes from cache.

Refreshes local candidate status and broadcasts to cluster.

Starts the candidate cache manager.

Types

candidate_cache/0

-type candidate_cache() :: #{node() => boolean()}.

state/0

-type state() :: #{cache := candidate_cache(), last_refresh := integer()}.

Functions

get_candidates()

-spec get_candidates() -> [node()].

Returns the current list of candidate nodes from cache.

handle_call(Request, From, State)

handle_cast(Request, State)

handle_info(Info, State)

refresh_local_status()

-spec refresh_local_status() -> ok.

Refreshes local candidate status and broadcasts to cluster.

start_link()

Starts the candidate cache manager.

terminate(Reason, State)