Chris Richardson - Documenting a service using the microservice canvas

This is a copy of an excellent blog article by Chris Richardson from his web site. He also has more information about this on GitHub.

In What’s a service - part 1? I described the key aspects of a service, which includes its API, and its dependencies. A good way to document a service and its structure is to use a microservice canvas. A microservice canvas is concise description of a service. It’s similar to a CRC card that’s sometime used in object-oriented design.

I first read about the canvas back in 2017 in an DZone article by Matt McLarty and Irakli Nadareishvili. I’ve since adapted the structure of the canvas so that it emphasizes the interface (top of the canvas) and the dependencies (bottom of the canvas) and de-emphasizes implementation (middle of the canvas).

Here is an example of a microservice canvas. It describes the Order Service, which is part of my book’s example FTGO application.

A service’s external view

The service’s external view is described by the following sections:
  • name - name of the service
  • description - a brief description of the service
  • capabilities - the business capabilities implemented by the service
  • service API - the operations implemented by the service and the domain events published by the service
  • quality attributes - the service’s quality attributes, which are also known as non-functional attributes
  • observability - includes health check endpoint, key metrics, etc.

A service’s dependencies

A service’s dependencies are described by the dependencies section, which consists of two parts
  • invokes - the operations, which are implemented by other services that this service invokes
  • subscribes - the messages, which includes events, that this service subscribes to

A service’s implementation

The canvas can also describe the service’s implementation, such as its domain model.

Example canvas

To learn more

Mike's Notes

  • Use this template which is available on GitHub.
  • Credit both Chris & Matt.
  • Closely matches what I use anyway but a lot better laid out.
  • Most of these metadata fields are already completed.
  • The existing project documentation generator could easily work with this template to batch output HTML and PDF files.
  • Will not be using Saga's, however, can work with workflow messaging.

No comments:

Post a Comment