Closed jipen closed 3 years ago
Thank you for the suggestion @jipen! Adding support for a terminate
-callback is a great idea.
I have created a pull-request to address this and will make a new release once it's merged.
I just released version 3.1.0. It should now contain support for the terminate callback. Please let me know if you have problems.
First, thanks for your work !
In order to bring a communication layer between my Elixir SFTP servers and a Phoenix web app (a gateway to monitor my servers), I've implemented a module, GatewayChannel, close to the one you give in the example (socket_client.ex) and added this module to my supervision tree. Everything runs ok except for termination: If one of my servers is stopped (such as by :init.stop() at top level), I'd like it to send a final message on the channel to inform the gateway that the server is no more available. But the GenServer terminate function I usually call for these type of "cleaning" won't execute in my GatewayChannel module (even with Process.flag(:trap_exit, true)). So could you add @callback terminate(reason, state) to gen_socket_client.ex as an enhancement or is there another way that I hadn't thought about to achieve this goal ?
Best regards.