4 Microservices Project Setup
This chapter covers
- Using
Hexagonal Architecturefor microservice projects - Setting up toolkits for the services
- Running a basic microservice application
- Making initial request to running application
It is very normal to say 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 at first, but you can see how easy it is if you apply some common software architecture pattern. Those patterns are mostly for solving the modularizaton problems to have testable components. Let’s see how we can apply those principles to a Go microservice project and perform some test to see how gRPC endpoints work.
4.1 Hexagonal Architecture
Hexagonal Architecture, proposed by Alistair Cockburn in 2005, is an architectural pattern that aims to build loosely coupled application components that can be connected to each other via ports and adapters. In Hexagonal Architecture, consumer arrives at application at Port via an Adapter and the output is sent from application through a Port to an Adapter. Therefore, Hexagonal Architecture is also known as Ports & Adapters. Using Ports and Adapters creates an abstraction layer that protects the core of the application from external dependencies. Now that we understand the components of Hexagonal Architecture in general, let’s dive a bit deeper for each of them.