Skip to content

Commit

Permalink
Upload expected initial contract
Browse files Browse the repository at this point in the history
  • Loading branch information
faraonc committed Jan 21, 2019
1 parent add3ac1 commit 7e30b9b
Show file tree
Hide file tree
Showing 7 changed files with 1,864 additions and 77 deletions.
55 changes: 31 additions & 24 deletions generate_int_proto.sh
Original file line number Diff line number Diff line change
@@ -1,66 +1,73 @@
#!/bin/bash


LIB_ROOT="/lib/"
USER_ROOT="./int/hwsc-user-svc/proto/"
DOCUMENT_ROOT="./int/hwsc-document-svc/proto/"
FILE_ROOT="./int/hwsc-file-transaction-svc/proto"
APP_ROOT="./int/hwsc-app-gateway-svc/proto/"

# generate protoc for our service
echo "Generating internal proto..."



# SAMPLE SERVICE
echo "Generating hwsc-grpc-sample-svc.pb.go..."
protoc int/hwsc-grpc-sample-svc/proto/hwsc-grpc-sample-svc.proto \
--go_out=plugins=grpc:.


echo "------------------------------------------------------------"

# USER SERVICE
echo "Generating hwsc-user-svc.pb.go, user.pb.go..."
OUTPUT_ROOT="./int/hwsc-user-svc/proto/"
protoc \
-I ./lib/ \
-I ${OUTPUT_ROOT} \
--go_out=plugins=grpc:${OUTPUT_ROOT} \
-I ${USER_ROOT} \
--go_out=plugins=grpc:${USER_ROOT} \
user.proto hwsc-user-svc.proto

protoc-go-inject-tag -input=${OUTPUT_ROOT}hwsc-user-svc.pb.go
protoc-go-inject-tag -input=${OUTPUT_ROOT}user.pb.go
sed -i'.orig' -e 's/`json:"-"`/`json:"-" bson:"-"`/g' ${OUTPUT_ROOT}*.pb.go

protoc-go-inject-tag -input=${USER_ROOT}hwsc-user-svc.pb.go
protoc-go-inject-tag -input=${USER_ROOT}user.pb.go
sed -i'.orig' -e 's/`json:"-"`/`json:"-" bson:"-"`/g' ${USER_ROOT}*.pb.go

echo "------------------------------------------------------------"

# DOCUMENT SERVICE
echo "Generating hwsc-document-svc.pb.go, document.pb.go..."
OUTPUT_ROOT="./int/hwsc-document-svc/proto/"
protoc \
-I ./lib/ \
-I ${OUTPUT_ROOT} \
--go_out=plugins=grpc:${OUTPUT_ROOT} \
-I ${DOCUMENT_ROOT} \
--go_out=plugins=grpc:${DOCUMENT_ROOT} \
document.proto hwsc-document-svc.proto

protoc-go-inject-tag -input=./int/hwsc-document-svc/proto/hwsc-document-svc.pb.go
protoc-go-inject-tag -input=./int/hwsc-document-svc/proto/document.pb.go
protoc-go-inject-tag -input=${DOCUMENT_ROOT}hwsc-document-svc.pb.go
protoc-go-inject-tag -input=${DOCUMENT_ROOT}document.pb.go
sed -i'.orig' -e 's/`json:"-"`/`json:"-" bson:"-"`/g' int/hwsc-document-svc/proto/*.pb.go
sed -i'.orig' -e 's/json:"is_public,omitempty" bson:"isPublic"/json:"is_public" bson:"isPublic"/g' int/hwsc-document-svc/proto/*.pb.go


#
echo "------------------------------------------------------------"

# FILE TRANSACTION SERVICE
echo "Generating hwsc-file-transaction-svc.pb2.py, hwsc-file-transaction-svc.pb2_grpc.py..."
python3 -m grpc_tools.protoc \
-I./int/hwsc-file-transaction-svc/proto \
-I ${FILE_ROOT} \
--python_out=./int/hwsc-file-transaction-svc/proto/ \
--grpc_python_out=./int/hwsc-file-transaction-svc/proto/ \
./int/hwsc-file-transaction-svc/proto/hwsc-file-transaction-svc.proto


echo "------------------------------------------------------------"

# APP GATEWAY SERVICE
echo "Generating hwsc-app-gateway .ts, .js, .pb"
OUTPUT_ROOT="./int/hwsc-app-gateway-svc/proto/"
protoc \
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
--plugin=protoc-gen-go=${GOPATH}/bin/protoc-gen-go \
-I ${OUTPUT_ROOT} \
--js_out=import_style=commonjs,binary:${OUTPUT_ROOT} \
--go_out=plugins=grpc:${OUTPUT_ROOT} \
--ts_out=service=true:${OUTPUT_ROOT} \
${OUTPUT_ROOT}hwsc-app-gateway-svc.proto
-I ./lib/ \
-I ${USER_ROOT} \
-I ${DOCUMENT_ROOT} \
-I ${FILE_ROOT} \
-I ${APP_ROOT} \
--js_out=import_style=commonjs,binary:${APP_ROOT} \
--go_out=plugins=grpc:${APP_ROOT} \
--ts_out=service=true:${APP_ROOT} \
${APP_ROOT}hwsc-app-gateway-svc.proto
Loading

0 comments on commit 7e30b9b

Please sign in to comment.