Closed 21it closed 4 years ago
I found that STM TChan is solved this issue for now
Sorry for the late reply - yes, PubSub should be relatively easy to achieve with the standard Haskell concurrency primitives without leaking memory.
The second question - is there and kind of callbacks similar to Erlang GenServer init and terminate for Replica processes? Init is supposed to be applied when client connects and Replica process is spawned, terminate is applied when client disconnects. If we have these callbacks then I think it will be possible to build PubSub - like things on top of it with MVars or STM.
This shouldn't be too hard to implement, but I gather you don't need this anymore, since TMChans
are automatically garbage collected when a client disconnects.
Hello @pkamenarsky! First of all, thanks for great library, I'm really enjoying it! Special thanks for examples which are working!
I see you might be pretty familiar with Erlang/OTP/Phoenix because you mentioned LiveView library in readme file. I have a question, does this library have something similar to Phoenix.PubSub? Or just Erlang pg2 - to have a groups of Replica processes currently running, which I want to be able to receive notifications of some events happened outside of Replica (DB entity updates, API notifications received, literally any kind of external IO)
The second question - is there and kind of callbacks similar to Erlang GenServer
init
andterminate
for Replica processes?Init
is supposed to be applied when client connects and Replica process is spawned,terminate
is applied when client disconnects. If we have these callbacks then I think it will be possible to build PubSub - like things on top of it with MVars or STM.I need this some kind of PubSub and process Registry for my app, and it's possible to do registry based on process ids, but without
terminate
callback memory will leak - I need to cleanup state from already disconnected/dead processes somehow. In Erlang I guess it's usually done withmonitor
function, and I'm sure it's Erlang-specific thing. If there is similar function for general Haskell processes including Replica processes - it might solve the issue as well.