Micro-Go is a golang project that implements Micro-service architecture using go-kit. In this project I implemented a microservice application that does string operations like concat, count, split, ...
The base idea behind this project was to work with go-kit, and learn how to implement a golang application using microservice architecture.
- Microservice in Golang
- Go-kit
Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are:
- Highly maintainable and testable
- Loosely coupled
- Independently deployable
- Organized around business capabilities
- Owned by a small team
The microservice architecture enables the rapid, frequent and reliable delivery of large, complex applications.
It also enables an organization to evolve its technology stack.
To see how does this microservice work, check the following schema:
Go kit is a programming toolkit for building microservices (or elegant monoliths) in Go. It solves common problems in distributed systems and application architecture, so you can focus on delivering business value.
Go is a great general-purpose language, but microservices require a certain amount of specialized support. RPC safety, system observability, infrastructure integration, even program design — Go kit fills in the gaps left by the standard library, and makes Go a first-class language for writing microservices in any organization.
Clone into repository and set up the services:
go run main.go
url:
[HOST]:[PORT]/uppercase
method:
POST
request:
type UppercaseRequest struct {
S string `json:"s"`
}
response:
type UppercaseResponse struct {
V string `json:"v"`
Err string `json:"err,omitempty"`
}
url:
[HOST]:[PORT]/lowercase
method:
POST
request:
type LowercaseRequest struct {
S string `json:"s"`
}
response:
type LowercaseResponse struct {
V string `json:"v"`
Err string `json:"err,omitempty"`
}
url:
[HOST]:[PORT]/count
method:
POST
request:
type CountRequest struct {
S string `json:"s"`
}
response:
type CountResponse struct {
V int `json:"v"`
}
url:
[HOST]:[PORT]/concatenate
method:
POST
request:
type ConcatenateRequest struct {
S string `json:"s"`
C string `json:"c"`
}
response:
type ConcatenateResponse struct {
V string `json:"v"`
Err string `json:"err,omitempty"`
}
url:
[HOST]:[PORT]/split
method:
POST
request:
type SplitRequest struct {
S string `json:"s"`
K string `json:"k"`
}
response:
type SplitResponse struct {
V []string `json:"v"`
Err string `json:"err,omitempty"`
}