Clarification EDIT: By “GoLang process”, here I am referring to separate x86_64 linux OS process running GoLang code. Sorry for confusion.
I know about NIFs / Ports. If you are claiming they solve my problem, please provide precise details (perhaps link to sample code) on how they solve my problem.
I have the following problem: There is a GoLang process I would like to put into the Erlang OTP supervision tree:
Erlang starts the GoLang process
if the GoLang process crashes / dies / becomes unresponsive, Erlang gets a notification
Erlang supervisor restarts the GoLang process as necessary
From my research, the two ways to do Erlang/Elixir interop is either NIF or Ports. I am not a fan of NIF, as crash in GoLang = crahse Erlang VM. The stdin/stdout message passing of Ports also sounds a bit weird.
I am wondering if there is any other way for Erlang/Elixir to “supervise” a GoLang process.
Use ports. There is nothing wrong of passing packets back and forth on stdin/stdout, if you control both sides.
The only downside of using ports is that there is no back pressure, so if the pipe accumulates too much packets the whole system will misbehave. There are some ways to add back pressure to ports, but you should design the system so that the port communication can never be the bottleneck in the first place.