Module em_pop_store

em_pop_store — DETS-backed peer table persistence.

Description

em_pop_store — DETS-backed peer table persistence.

Provides open/close/save/load against a named DETS table. Called exclusively by em_pop_node.

One table per node, named em_pop_<agent_name>. File: <persist_dir>/em_pop_<agent_name>.peers.

Function Index

close/1Close the DETS table.
load/1Read all saved peers back as a map.
open/2Open (or create) the DETS table.
save/2Replace the entire table with the current peer map.

Function Details

close/1

close(Name::atom()) -> ok | {error, term()}

Close the DETS table.

Errors (e.g. already closed) are returned as-is; callers may ignore.

load/1

load(Name::atom()) -> #{binary() => term()}

Read all saved peers back as a map.

Returns #{} on any error so the caller never needs to handle failure.

Note: last_seen values in restored #peer{} records are monotonic timestamps from a previous VM session and must be reset by the caller after loading to prevent immediate stale eviction.

open/2

open(Name::atom(), Dir::string()) -> {ok, atom()} | {error, term()}

Open (or create) the DETS table.

Name — unique atom per node, e.g. em_pop_hackernews_filter Dir — directory path string; created automatically if absent

save/2

save(Name::atom(), Peers::#{binary() => term()}) -> ok | {error, term()}

Replace the entire table with the current peer map.

Peers is #{PeerId => #peer{}} — the internal em_pop_node peer map.


Generated by EDoc