bookshelf
├── README.md
├── app # application
│ ├── adapter # interface definition. files in app/service call external services based on the interface.
│ ├── cmd # set-up functions and main function
│ ├── config
│ ├── external # external service callers that implement app/adapter
│ ├── model # the most important thing. models depend on nothing.
│ ├── pkg # packages that do not depend on the project (this microservice itself)
│ ├── server # responsible for validating requests and handling requests and events
│ └── service # corresponds to use-case layer in the clearn architecture
├── client # generated code based on proto
│ ├── api
│ └── event
├── docker-compose.yaml # local env prep
└── proto
├── api
└── event
- mod proto/api or proto/event
- specify api or event, substitute xxxx with the file name and exetute the command belown in the proto directory
$ protoc --go_out=../client --go_opt=paths=source_relative \
--go-grpc_out=../client --go-grpc_opt=paths=source_relative \
[api or event]/xxxx.proto
- change files in the app directory
Note: (core) model <- service <- adapter <- external (outer)
Note: Change adapter -> external. Don't do the other around.
- Copy app/config/.envrc and paste it to Termial.
- In the root directory (bookshelf in this case), execute
docker-compose up -d
- In the root directory (bookshelf in this case), execute
go run app/cmd/main.go app/cmd/setup.go
Assuming that tools are installed on your computer.
$ grpcurl -plaintext localhost:8080 BookshelfService/ListBooks
$ grpcurl -plaintext -d '{"title": "sample", "category": 1, "author": "satoshi"}' localhost:8080 BookshelfService/AddBook
$ grpcurl -plaintext -d '{"id": 1}' localhost:8080 BookshelfService/GetBook