Mooncore.Endpoint.Socket.Clients (mooncore v0.2.5)

Copy Markdown

Tracks WebSocket client PIDs organized by group and channel.

Uses an ETS :bag table for lock-free concurrent reads — list_members/3 reads directly from ETS without going through the GenServer. Writes (add/remove) are serialized through the GenServer for consistency.

ETS table name is :mooncore_{pool} (e.g. :mooncore_default).

Usage

Started automatically by Mooncore.Application for each pool in config.

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Full state as a nested map. Reads from ETS.

All channels and PIDs for a group. Reads from ETS.

List PIDs for a channel. Reads directly from ETS — no GenServer call.

Functions

add_member(group, channel, pid, pool \\ :default)

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

init(name)

Callback implementation for GenServer.init/1.

list_all(pool \\ :default)

Full state as a nested map. Reads from ETS.

list_group(group, pool \\ :default)

All channels and PIDs for a group. Reads from ETS.

list_members(group, channel, pool \\ :default)

List PIDs for a channel. Reads directly from ETS — no GenServer call.

remove_member(group, channels, pid, pool \\ :default)

start_link(list)