derek-zhou
How to wrap a library written in another language
I want to wrap a library written in another language so it can be used in Elixir. Because the library contains significant state, I am reluctant to wrap it with NIF. I can make it a command line tool and use an Erlang port to communicate with it but then I lose parallelism. My current thinking is to make it a daemon process listening on a UNIX domain socket and communicate with it. What will you guys do in this situation? Is there a good example of a simple protocol to talk to a backend server? I feel HTTP is a little too heavy for my case.
Most Liked
fceruti
I’ve used ZeroMQ to communicate between two different processes written in different languages with pretty good results. They have libraries for many languages, and I think there’s a community driven one for Elixir (haven’t tested it).
From their docs:
ZeroMQ (also spelled ØMQ, 0MQ or ZMQ) is a high-performance asynchronous messaging library, aimed at use in distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ZeroMQ system can run without a dedicated message broker.
ZeroMQ supports common messaging patterns (pub/sub, request/reply, client/server and others) over a variety of transports (TCP, in-process, inter-process, multicast, WebSocket and more), making inter-process messaging as simple as inter-thread messaging. This keeps your code clear, modular and extremely easy to scale.
ruslandoga
You can try using a pool of instances of that library, for example, with GitHub - dashbitco/nimble_pool: A tiny resource-pool implementation for Elixir · GitHub, it might help (or not) with parallelism.
wanton7
Would it be possible to multiplex multiple calls through single port? HTTP/2 is pretty much doing the same.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








