How I became best-in-the-world at accessing SalesForce from Elixir (and maybe Erlang too)

Over the last several months, I have been playing with Elixir.
* Reading Programming Elixir
* Reading Elixir in Action
* Following Chris McCord’s excellent Elixir tutorial
* Watching the videos from Elixir Conf
* Writing a simple IRC bot for the Puppet Labs interns
* Demo’d mesh networking, supervision trees, and hot code reloading with the IRC bot as a vehicle
* Using a hackday to write and then rewrite a service w/ Ruby/Sinatra, JRuby/TorqueBox, and Elixir/Plug with Elixir resulting is 55X the Ruby/Sinatra throughput and 2.3X the JRuby/TorqueBox throughput
* Running through the exercism.io Elixir tasks

I never really (and still don’t) feel like I know Elixir very well, but I am very excited by its promise and the robustness of the Erlang Virtual Machine.

Some of my current work at Puppet Labs involves creating automation to pull data from SalesForce, combine it with additional data sources, crunch the data, and report out. I am competent (not exceptional, but competent) with the SalesForce API and the databasedotcom Ruby gem.

I have an upcoming service that will need to access SalesForce data, and I have been writing it twice: once in Ruby (which will likely be deployed via JRuby) and once in Elixir. This may seem silly or wasteful, but I have certainly been far more deliberate about the service’s robustness as a result. Asking questions like
* How long are you willing to wait for a response?
* Can I tell you to go away and try again later?
* How is the load modeled, in terms of quantity, frequency, content?

Earlier this week I got to the point where I could no longer fake the SalesForce data, and I had to connect it for real. No problem for Ruby, just add gem 'databasedotcom'. For Elixir, hex.pm: nothing, Google: nothing. Let’s check Erlang. Well, there’s ErlForce, but it uses the old SOAP API *and* hardcodes a version that doesn’t even answer anymore.

Well, crap.

Should I write an Elixir client library? I don’t particularly *want* to write one. Screw it, I’m gonna write one…

A few hours later, I had a workable version where I could log in, figure out which SalesForce host I should utilize, see what data exists, introspect each of the SalesForce objects and their attributes (useful for dynamically creating database tables with the proper data types), and perform generic queries. In other words, 90%+ of the functionality I use in the databasedotcom gem. In a few hours! That’s mostly Elixir, very little Jeff.

I uploaded it to hex.pm, the Elixir/Erlang package repository.

No one else is using it, yet. Although, on the commute the following morning, I had a stunning and terrifying thought: Because no one else is accessing SalesForce from Elixir (as gauged by lack of libraries and questions about it), I am the best (and maybe only) in the world. This position would be trivial for someone like Fred H├ębert to usurp, but, for now, I’m going enjoy it, and work dilligently to maintain.

Comments are closed.