I'm learning erlang and I'm very fascinated by the mnesia db. I want to build some real world application in C# / F# using erlang as backend.
I'm searching for a good solution to communicate with erlang nodes from the outside world.
What I found so far:
(A) OTP.net, an opensource .net library implementing the 'native' erlang comunication protocol
Problems here:
(B) Use ports / sockets in erlang and implement a custom protocol.
Problems here:
Do you have any advice, experience in this topic?
Should I work on the OTP.net library to make it fit my needs or try to implement a new protocol from scratch?
What about a JSON or REST solution? Is there any erlang library that would do the trick?
The port/socket solution is a good idea and is not hard as it may seem. Google's protocol buffers is just what you need. It is very easy to use, efficient and maintainable. It has implementations for C#, erlang, java, python and many more (See OtherLanguages and developer guide)
You can use protocol buffers to define the request and response protocol structure. Then use it to communicate between erlang and any other supported language. The tutorial will explain it all. After that all you need to do is send the response over the port.
The advantage of this approach is that:
If you want to implement a REST API in Erlang there is only one thing to do. Use the excellent MochiWeb Kit to build your own HTTP server that implements your protocol.
Don't panic, it really is easier than it would appear.
There are a number of tutorials about how to do it including a screencast set from the Pragmatic Programmers.
It comes with a complete set of json libraries, so you'll be fine!
Sure, you can do REST with Erlang, see e.g. http://www.infoq.com/articles/vinoski-erlang-rest - if appropriate for your apps' needs, REST is an excellent approach. (Pycon Italia Tre, next week in Florence, has sessions on Erlang/Python cooperation, see www.pycon.it if you're near Tuscany;-).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With