Tuesday, May 10, 2022

Pattern: Service Template

 Problem

How can a team quickly create and set up a maintainable codebase for a production-ready service so they can start developing its business logic?

Forces

  • A service must implement
  • Build logic that builds, and tests the application and also packages into a production-ready format, such as a Docker container image.
  • Cross-cutting concerns such as externalized configuration, logging, health checks, metrics, service registration and discovery, circuit breakers. There are also cross-cutting concerns that are specific to the technologies that the microservices uses.
  • Creating a new microservice should be fast and easy
  • It should be fast and straightforward to update existing services when the requirements for build logic and cross-cutting concerns change.

Solution

Create a source code template that a developer can copy in order to quickly start developing a new service. A template is a simple runnable service that implements the required build logic and cross-cutting concerns along with sample application logic.



Resulting context

This pattern has the following benefits:

  • a developer can quickly and easily start developing a new microservice.
  • it ensures that cross-cutting concerns are implemented in a standardized consistent way
  • it encourages developers to ‘do the right thing’
  • it’s a form of copy/paste programming. When you change the service template due to changing requirements, you must update existing services individually. Creating service repositories by forking the service template repository can minimize the work by leveraging Git. However, there’s a risk that services created at different points in time will diverge.
  • you need a service template for each programming language/framework that you want to use. This can be an obstacle to adopting a new programming language or framework.

This pattern has the following drawbacks:

This pattern has the following issues:

You may also like

Kubernetes Microservices
Python AI/ML
Spring Framework Spring Boot
Core Java Java Coding Question
Maven AWS