3 ms·
> Doing websockets with something like Phoenix/Elixir means that you have to bring in Redis for pubsub between nodes I haven't even tried this myself yet, but
by derefr 10y ago
> Doing websockets with something like Phoenix/Elixir means that you have to bring in Redis for pubsub between nodes
I haven't even tried this myself yet, but it's been stewing in the back of my mind: you should be able to (efficiently) pass sent messages between your nodes using server-to-server websocket connections.
You just need
• some supervised GenServers that establish and manage long-lived connections to your peers using a websocket client library, e.g. https://github.com/jeremyong/websocket_client https://github.com/jeremyong/websocket_client or https://github.com/ninenines/gun https://github.com/ninenines/gun
• a "server peer RPC" Phoenix Channel, that authenticates server peers in its connect/3 using a common pre-shared key (ala Erlang's own "cookie") or somesuch
---
Going a bit further: once you have these two components set up, you can actually extend it out to being a fully-fledged transport layer for the Erlang distribution protocol.
Look at the guide at http://erlang.org/doc/apps/ssl/ssl_distribution.html http://erlang.org/doc/apps/ssl/ssl_distribution.html. It mentions two reference implementations of a distribution-protocol connection handler:
• inet_tcp_dist
(https://github.com/erlang/otp/blob/master/lib/kernel/src/inet_tcp_dist.erl https://github.com/erlang/otp/blob/master/lib/kernel/src/ine...)
• inet_tls_dist (https://github.com/erlang/otp/blob/master/lib/ssl/src/inet_tls_dist.erl https://github.com/erlang/otp/blob/master/lib/ssl/src/inet_t...)
Between the two, the API an `inet_websocket_dist` would need to follow is pretty clear.
With such a thing, you get cluster-presence and cookie-based auth "for free", and automatic leader election for use with `global`. But most of what you want is probably just rpc:multicall/3.
- phamilton 10y agosigh... > Any sufficiently complicated concurrent program in another language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang. Except this time, it's already on BEAM...