SOA Ruby Development with Foreman
Foreman is an intra-app process manager used in a development environment. Although its main use case is that, I’ve started to use it to manage inter-app dependencies as well.
Pow is a simple Rack server that also contains a DNS server capable of port proxying.
These two tools combined allow for easy management of a SOA based local development environment.
Imagine a primary Ruby on Rails application that depends on a couple of other services (Rails, Rack, Sinatra, Faye, Node.js etc) to be fully functional in development. These other services/apps could have their own Gemfile and process dependencies (worker, clock etc) that are also managed locally by Foreman.
Service Oriented Foreman by Matthew Kocher describes an approach that uses Foreman to manage these inter-app processes. Here’s a more complete example of that approach:
Assuming the Service1 App
has the relevant .foreman
file then typing foreman start
in the Primary App
terminal
will also start all the associated services specified in the primary Procfile.
In order to easily keep the associated services up-to-date (which may be developed by other teams), it’s nifty to include a helper script in the Primary App that helps make this easy. Here’s an example of what that may look like:
This setup has been working well enough with just a few services in development and using Webmock to stub out requests in the test environment. Going forward, each service could also provide a private library/gem that mocks its interface out in the test environment.
There are other approaches to managing services in development that are worth evaluating like service stubs and more comprehensively using Vagrant as alluded to in this talk.