I would like to execute some performance heavy tasks within an Elixir Phoenix application. Rather than sending the data elsewhere (external service), processing it, and returning it to the Phoenix app, I'd like to process it in place. Go has a lot of data science-y packages and so I'd like to use those within the Phoenix application. How can I do this?
I've researched and discovered Rustler (Rust) which uses NIFs. I could not find a Go variant or similar.
Use System.cmd/3
to spawn the external Go process.
I frankly doubt there are any native bindings to Go available.
If you can, do not use NIFs, as panic in such code can cause your whole VM to crash. Instead BEAM has few different options for FFI:
erl_interface
which is Port, but with some utilities for simplifying communication