- Hands-On Microservices with Kubernetes
- Gigi Sayfan
- 155字
- 2021-06-24 13:46:44
Understanding middleware
Go kit is composable, as demonstrated in the preceding onion diagram. In addition to the mandatory transports, endpoints, and services, Go kit uses the decorator pattern to optionally wrap services and endpoints with cross-cutting concerns, such as the following:
- Resiliency (for example, retries with exponential backoff)
- Authentication and authorization
- Logging
- Metrics collection
- Distributed tracing
- Service discovery
- Rate limiting
This approach of a solid core with a small number of abstractions, such as transports, endpoints, and services, that can be extended using a uniform mechanism of middleware is easy to comprehend and work with. Go kit strikes the right balance between providing enough built-in functionality for middleware and leaving the floor open to your needs. For example, when running on Kubernetes, service discovery is taken care of for you. It's great that you don't have to work around Go kit in this case. Features and capabilities that you don't absolutely need are optional.