Today, I’m gonna tell you a secret: you’ve been doing microservices all these years and no one told you.

How?

Well, if you’re not familiar with the Unix/Linux shell, maybe now is a good time to see what Brian Kernighan has to say about Unix pipelines:

OK, so let’s take a look at an example, a simple bash shell sequence that pipes commands together like so:

$ ls | grep ‘^s’ | sort -r

What this says is essentially: generate an reverse-ordered list of entries that start with a “s”. Let’s call this the s-list service, with:

ls … a generator, which takes an implicit parameter, the current directory and produces a list of things (directory entries, really).

grep … a filter, taking a list of things and producing another list of things (which may or may not be non-empty).

sort … a post-processor, taking a list of things and producing another, ordered version of this list.

So, you’ve really got three services here: the generator service, the filter service, and the post-processor service; each can evolve independently, can be replaced by a superior implementation, and most importantly: it can be treated as a black box. As long as the interface, that is, how the data flows out of one and into the other, stays the same, the overall service composition will work and the result will be the same.