jayjun / rambo

Run your command. Send input. Get output.
MIT License
204 stars 23 forks source link

Usage in GenServers #9

Closed lud closed 3 years ago

lud commented 3 years ago

Finally ! It took me so long to find a simple yet appropriate library for what I need. So big thanks to you :)

Now, I see in the readme that usage in GenServers is discouraged and calls should be wrapped in a Task. Why not, but I would like to know what messages could be sent that would interfere with the gen_server loop? As Rambo.run is blocking, once the function call returns, are there still messages that could be received?

Thanks again!

jayjun commented 3 years ago

Rambo is pretty simple, it merely opens an Erlang port from your calling process and then starts a receive loop.

The problem is running your own loop interferes with GenServer’s receive loop.

lud commented 3 years ago

Yes but Rambo.run is blocking. So would you receive messages after the function has returned?

lud commented 3 years ago

Ok I got it backwards. It is actually the messages that a GenServer would receive that would be received by rambo and not understood.

Got it.