https://github.com/alextanhongpin/go-onion
Onion architecture in Golang
https://github.com/alextanhongpin/go-onion
golang onion rest service
Last synced: 5 months ago
JSON representation
Onion architecture in Golang
- Host: GitHub
- URL: https://github.com/alextanhongpin/go-onion
- Owner: alextanhongpin
- Created: 2017-11-25T22:20:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-03T09:44:50.000Z (almost 7 years ago)
- Last Synced: 2024-04-14T23:09:41.171Z (about 1 year ago)
- Topics: golang, onion, rest, service
- Language: Go
- Size: 10.7 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-onion
Attempting clean architecture with golang. Each services will be split into a folder with the suffix `-service` (e.g. `food-service`).
Each folder will contain the following files:
1. `model.go` which contains business logic and model validation. Calls the `Store` which is an API to data source such as Database or external HTTP Request.
2. `store.go` which is basically the Data Access Layer. Connects to the Database and does not contain any business logic. Provides an interface that allows itself to be mocked.
3. `route.go` which is the HTTP Endpoint for the service. Is responsible for constructing the request params for the service and returning the response or error after calling the service. Dumb endpoint, as it does not contain any business logic. Makes it easier to swap transport (GraphQL, gRPC, cron, etc) since the core logic is contained in the `Model`.
4. `main.go` which binds the `Model`, `Store` and `Route` together through dependency injection.
5. `interface.go` which contains the interface for each component and also define the request and response structs.## TODO
- add pprof for cpu, mem, alloc
- add timeout and for client and http
- add nettrace
- load testing
- benchmarking