Pipeline

A pipeline is another example of a microservice connecting pattern. If you have made use of the shell on a *NIX system, then you have certainly piped the output of one command to another command. The programs on a *NIX system such as ls, sort, uniq, and grep are designed to perform just one task; their power comes from the ability to chain the tools together to build quite complex workflows. For instance, this command:

ls -1| cut -d . -f 2 -s | sort |uniq

This command will list all the unique file extensions in the current directory. It does this by taking the list of files, then cutting them and taking the extension; this is then sorted and finally passed to uniq which removes duplicates. While I wouldn't suggest having a microservice for such trivial actions as sorting or deduplicating, you might have a series of services which build up more and more information.

Let's imagine a query service that returns a collection of company records:

| Company Id| Name | Address | City | Postal Code | Phone Number |

This record is returned by our company lookup service. Now we can pass this record onto our sales accounting service which will add a sales total to the record:

| Company Id| Name | Address | City | Postal Code | Phone Number | 2016 orders Total |

Now that record can be passed onto a sales estimate service, which further enhances the record with an estimate of 2017 sales:

| Company Id| Name | Address | City | Postal Code | Phone Number | 2016 orders Total | 2017 Sales Estimate |

This sort of progressive enhancement could be reversed too by a service that stripped out information which shouldn't be presented to the users. The record might now become the following:

| Name | Address | City | Postal Code | Phone Number | 2016 orders Total | 2017 Sales Estimate |

Here we have dropped the company identifier because it is an internal identifier. A microservice pipeline should be bidirectional so that a quantum of information is passed into each step in the pipeline and then passed back out again through each step. This affords services the opportunity to act upon the data twice, manipulating it as they see fit. This is the same approach used in many web servers where modules such as PHP are permitted to act upon the request and the response. A pipeline can be seen illustrated here:

Pipeline
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset