Module em_filter_server

WebSocket Client for em_disco Connectivity.

Behaviours: gen_server.

Authors: Steve Roques.

Description

WebSocket Client for em_disco Connectivity

Manages a single persistent WebSocket connection to ONE em_disco node. em_filter_sup starts one server per configured disco node.

Transport is determined by em_filter_sup:read_disco_nodes/0: tcp — plain WebSocket (ws://) tls — TLS WebSocket (wss://)

TLS uses verify_peer with the system CA store and sets SNI to the target host dynamically so wildcard certificates (*.roques.me) are accepted correctly by the Erlang SSL stack.

Startup sequence

1. Open a Gun connection (tcp or tls) to the disco address. 2. Upgrade to WebSocket on /ws. 3. Send a register frame to announce the agent name. 4. Send an agent_hello frame with capabilities (if any). 5. Initialise the memory backend.

Reconnection

On WS close or connection loss the gen_server stops and the supervisor restarts it, which reconnects the agent to em_disco.

Function Index

code_change/3
handle_call/3
handle_cast/2
handle_info/2
init/1
start_link/4Starts a server linked to one specific disco node.
terminate/2

Function Details

code_change/3

code_change(OldVsn, State, Extra) -> any()

handle_call/3

handle_call(Req, From, State) -> any()

handle_cast/2

handle_cast(Msg, State) -> any()

handle_info/2

handle_info(Info, State) -> any()

init/1

init(X1) -> any()

start_link/4

start_link(AgentName::atom(), HandlerModule::module(), Config::map(), X4::{string(), inet:port_number(), tcp | tls}) -> {ok, pid()} | {error, term()}

Starts a server linked to one specific disco node.

The server name encodes host + port so multiple workers for the same agent have distinct registered names: rss_filter_localhost_8080_server rss_filter_em_disco_roques_me_443_server

terminate/2

terminate(Reason, State) -> any()


Generated by EDoc