Skip to content

Commit

Permalink
Merge pull request #26 from dpakach/go-protobuf-v3
Browse files Browse the repository at this point in the history
Go protobuf v2
  • Loading branch information
dpakach authored Jan 23, 2021
2 parents 9041193 + c720ec9 commit 5b33e5c
Show file tree
Hide file tree
Showing 29 changed files with 1,649 additions and 1,346 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.12
go-version: 1.15
id: go

- name: Check out code into the Go module directory
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Now restart he service with following command
make restart-service SERVICE=posts
```

You will also need to install go protobuf dependency along with [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway) or the code generation on the server side. First you will need to have the protoc compiler for protobuf files. You can installit following [this](https://developers.google.com/protocol-buffers/docs/gotutorial#compiling-your-protocol-buffers) guide. After that install grpc-gateway and its required dependencies from [here](https://github.com/grpc-ecosystem/grpc-gateway). With all the dependencies out of the way, you should be ready to go.

### Architecture
Zwitter is composed of five different microservice components. These services are containerized using docker and can be run using docker-composer to start the whole system.

Expand Down Expand Up @@ -99,7 +101,6 @@ Available commands
api Auto-generate grpc go sources
clean Clean all build products
client Build the client binary
dep Download go dependencies
docker-build Build the docker image of the service
docker-run Build and run the service in a docker container
Expand Down
15 changes: 6 additions & 9 deletions auth/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
SERVER_OUT := "bin/server"
CLIENT_OUT := "bin/client"
API_OUT := "api/authpb/api.pb.go"
API_REST_OUT := "api/authpb/api.pb.gw.go"
PKG := "github.com/dpakach/zwitter/auth"
SERVER_PKG_BUILD := "${PKG}/server"
CLIENT_PKG_BUILD := "${PKG}/client"
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
VERSION := 1.0
GOPATH ?= '${HOME}/go'

.PHONY: all api server client
.PHONY: all api server

all: server

Expand All @@ -17,7 +16,8 @@ api/authpb/api.pb.go: api/auth_api.proto
-I/usr/local/include \
-I${GOPATH}/src \
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=plugins=grpc:api \
--go_out=api \
--go-grpc_out=api \
api/auth_api.proto

api/authpb/api.pb.gw.go: api/auth_api.proto
Expand All @@ -33,7 +33,7 @@ swagger: api
-I/usr/local/include \
-I${GOPATH}/src \
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--swagger_out=logtostderr=true:./swagger \
--openapiv2_out=logtostderr=true:./swagger \
api/auth_api.proto

docs: swagger ## Generate swagger documentation files
Expand All @@ -46,11 +46,8 @@ dep: ## Download go dependencies
server: dep ## Build the server binary
@go build -v -o $(SERVER_OUT) $(SERVER_PKG_BUILD)

client: dep ## Build the client binary
@go build -v -o $(CLIENT_OUT) $(CLIENT_PKG_BUILD)

clean: ## Clean all build products
@rm -rf $(SERVER_OUT) $(CLIENT_OUT)
@rm -rf $(SERVER_OUT)

docker-build: ## Build the docker image of the service
docker build -t zwiter/auth:$(VERSION) --build-arg service_name=auth -f ../service/Dockerfile .. --no-cache
Expand Down
194 changes: 1 addition & 193 deletions auth/api/authpb/auth_api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5b33e5c

Please sign in to comment.