pedrogarrett
Calling Elixir from Ruby
What is the best (or maybe simplest) way to call Elixir functions from Ruby?
I have a Rails application in which we are gradually porting functions in it over to an Elixir application. I could, of course, add Phoenix to the Elixir app and make http/json calls to it, but it seems like there ought to be a more efficient method.
Most Liked
karmajunkie
This isn’t really an Elixir/Ruby problem so much as a systems integration issue—anything you’d do to integrate two services normally should also apply.
HTTP calls are probably the least problematic as you can treat them synchronously. However if you can handle asynchronicity in the Rails application, then my favorite means of doing this kind of thing is a durable message queue. You’ve got a plethora of choices there ranging from sidekiq-style queues in Redis (and there are at least a couple of options for consuming sidekiq format messages in Elixir) to AMQP servers like RabbitMQ to something hosted like AWS SQS. Treat the functions as command messages and send back a response message from Elixir to be further dealt with by the Rails app.







