Member-only story

How To Ensure Reliable Inter-Service Communication With Contracts

Leverage several open-source tools to prevent breaking changes between your services

Ashley Peacock
Better Programming
Published in
5 min readDec 21, 2021

--

Photo by Cytonn Photography on Unsplash

You’ve just deployed a change to an API that your team owns, that’s used by several internal clients. All the tests were green, but when deployed, several of the clients’ integrations suddenly started to produce errors!

In the API world we live in, this is an extremely common scenario. There are some techniques we can use to help detect issues between services sooner, and they come in the form of contracts.

What Are Contracts?

In the business world, a contract defines how two companies are going to do business. They both set out terms and come to an agreement — company A will provide company B with X, and company B return Y to company A.

The same is true for software, just on a smaller scale (and typically with far less writing!). Implementation will vary depending on the programming language you’re using, but in most modern languages they typically take the form of an interface.

Similarly, in the business world, contracts can be broken. If you change the return value of a method from an integer to a string, then you’ve broken your contract with any…

--

--

Ashley Peacock
Ashley Peacock

Written by Ashley Peacock

Staff Software Engineer, Architect & Author

Responses (1)

Write a response