Module em_filter_sup

em_filter Top-Level Supervisor.

Behaviours: supervisor.

Authors: Steve Roques.

Description

em_filter Top-Level Supervisor

Manages the em_filter_server worker pool and the em_pop Population Protocol sub-supervisor.

Strategy: one_for_one. • em_pop_sup — permanent child, started at application boot. • em_filter_server workers — added dynamically via start_agent/3, each with its own unique child id.

When start_agent/3 is called, one em_filter_server worker is started per configured disco node. If the Config map contains a pop_port key, an em_pop Population Protocol node is also started and registered in em_pop_sup's ETS registry.

Node format in emergence.conf

nodes = localhost:8080, disco.example.com

Port resolution (when no port is given): localhost / 127.0.0.1 → 8080, plain TCP any other host → 443, TLS

Explicit port always wins: localhost:9000 → 9000, plain TCP example.com:8080 → 8080, plain TCP example.com:443 → 443, TLS

em_pop Config keys

pop_port => pos_integer() — required to enable em_pop pop_peers => [{Host, Port}] — bootstrap peers (optional) pop_stale_timeout => pos_integer() — default 30 000 ms pop_gossip_interval => pos_integer() — default 5 000 ms (0=off) pop_max_peers => pos_integer() — default 200

Function Index

start_agent/3Starts one worker per configured disco node for the agent.
start_link/0
stop_agent/1Stops all workers and the em_pop node for the given agent.

Function Details

start_agent/3

start_agent(AgentName::atom(), HandlerModule::module(), Config::map()) -> {ok, pid()} | {error, term()}

AgentName: Unique atom identifying the agent.
HandlerModule: Module exporting handle/2.
Config: Agent options map.

Starts one worker per configured disco node for the agent.

Node list is taken from (in priority order): 1. disco_nodes key in Config map (useful for testing) 2. EM_DISCO_HOST / EM_DISCO_PORT environment variables 3. [em_disco] nodes = ... in emergence.conf 4. Default: [{"localhost", 8080, tcp}]

If Config contains pop_port, an em_pop node is also started and the capability vector is derived from the capabilities list.

Returns {ok, Pid} of the first successfully started worker.

start_link/0

start_link() -> {ok, pid()} | {error, term()}

stop_agent/1

stop_agent(AgentName::atom()) -> ok | {error, not_running}

Stops all workers and the em_pop node for the given agent.

Returns {error, not_running} if no matching worker is found.


Generated by EDoc