AR6: Reliability across services: deadlines, retries, idempotency, outboxes and contracts

Lesson 5 of 5 · reading 15–25 minutes; practice and project time is on the module page

Contracts and versions

🎯You'll be able to

Write a contract between services, check it with contract tests, and change it safely with versions.

🏠The everyday picture

A tiffin service's printed menu card is a promise: these dishes, these prices, these hours. Customers plan around it. Changing it without notice upsets people; printing a new card for next month doesn't.

📘What it really is

📝A worked example

Input: a request to make the notify service accept email addresses as well as phones.

Steps:

  1. Safe option: add an optional to.email; requests with only to.phone work as before.
  2. Breaking option: rename to.phone to to.mobile. That breaks every caller.
  3. If it must happen, publish v2 beside v1, move callers, then retire v1 with a date.
  4. Add contract tests for the new field and keep the old ones.

Expected output: a change that adds without breaking, or a new version with a plan for the old one.

🌍Where it's used

📝Case scenario

A delivery platform renamed eta to estimatedArrival in its tracking API "to be clearer". Restaurant apps still reading eta showed blank times for a day. Adding the new field beside the old one, and removing eta months later in a new version, would have broken nobody.

🖱️Try it

Read contracts/notify-v1.json and list one change that would be safe and one that would need v2. Success: you explain why each is safe or breaking for an existing caller.

⚠️Common mistakes

🛠️For your project

Project 2's tests 1 and 2 check the notify service against contracts/notify-v1.json: health, 202, 400 and 422 with error.

✅Quick check

What is the difference between a 400 and a 422 in the kit's contract?

Show the answer

400 is a malformed request; 422 is a well-formed one the service can't act on, such as an unknown template.

How do you make a breaking change to a contract safely?

Show the answer

Publish a new version beside the old one, move callers, then retire the old one with notice.

← PreviousThe outbox
ProLearners Assist