4 Microservices Project Setup
This chapter covers
- Using
Hexagonal Architecturefor microservice projects - Setting up toolkits for the services
- Running a basic microservice application
- Making the initial request to running application
It is very normal to ask How should I structure my project? before writing the first line of your Go microservice project. The answer to this question might seem very difficult initially, but you can see how easy it is to apply some common software architecture patterns. Those patterns are mostly for solving the challenges like building modular projects to have testable components. Let’s see how to apply those principles to a Go microservice project and perform some tests to see how gRPC endpoints work.
4.1 Hexagonal Architecture
Hexagonal Architecture (https://alistair.cockburn.us/hexagonal-architecture/), proposed by Alistair Cockburn in 2005, is an architectural pattern that aims to build loosely coupled application components that can be connected via ports and adapters. In this pattern, the consumer arrives at the application at Port via an Adapter, and the output is sent through a Port to an Adapter. Therefore, Hexagonal Architecture is also known as Ports & Adapters. Using Ports and Adapters creates an abstraction layer that isolates the application's core from external dependencies. Now that we understand the components of Hexagonal Architecture in general let’s dive deeper into each.