[wip] websockets should have their own supervision tree

I also hate this bullshit of

- fd_client having such a stupid name
- websocket lib needs some love

basically I think this should be the approach:

renames:

- fd_clients    -> fd_http
- fd_client_man -> fd_http_client_man
- fd_client_sup -> fd_http_client_sup
- fd_client     -> fd_http_client
- fd_cache      -> fd_wfc_cache

new trees:

- tetris        -> new tree
- websockets    -> probably should fall into http supervision tree

Notes:
- fd_client_man is necessary because someone needs to own the listen socket
- rewrite fd_client as gen_server
This commit is contained in:
2025-10-27 10:35:05 -07:00
parent 1aed42598a
commit 4e48d6b40b
7 changed files with 458 additions and 140 deletions
+13 -1
View File
@@ -2,7 +2,11 @@
%
% manages state for a single game of tetris
%
% https://www.erlang.org/docs/24/man/gen_server
% sends parent process messages `{tetris, String}` where String is an encoded
% JSON blob meant to be sent to the page script in /priv/static/js/ts/tetris.ts
%
% Refs:
% 1. https://www.erlang.org/docs/24/man/gen_server
-module(fd_tetris).
-behavior(gen_server).
@@ -27,6 +31,14 @@
%% caller context below this line
%%-----------------------------------------------------------------------------
-spec ws_msg(Tetris, Message) -> ok
when Tetris :: pid(),
Message :: fd_ws:ws_msg().
ws_msg(Tetris, Msg) ->
gen_server:cast(Tetris, {ws_msg, Msg}).
-spec start_link() -> {ok, pid()} | {error, term()}.
start_link() ->
gen_server:start_link(?MODULE, [self()], []).