From 8b4424c518ef0892fbd32adc3bca6a35ade0cc5b Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 9 Nov 2022 14:18:51 +0800 Subject: [PATCH] refactor(gRPC): update go proto file --- Makefile | 8 ++++++++ rpc/proto/gorush.pb.go | 36 ++++++++++++++++-------------------- rpc/proto/gorush.proto | 3 +-- rpc/proto/gorush_grpc.pb.go | 11 ++++++++--- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index c83f927..8ef3827 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ GOFILES := $(shell find . -name "*.go" -type f) TAGS ?= sqlite LDFLAGS ?= -X 'main.Version=$(VERSION)' +PROTOC_GEN_GO=v1.28 +PROTOC_GEN_GO_GRPC=v1.2 + ifneq ($(shell uname), Darwin) EXTLDFLAGS = -extldflags "-static" $(null) else @@ -163,6 +166,11 @@ clean: find . -name *.db -delete -rm -rf release dist .cover +.PHONY: proto_install +proto_install: + $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GEN_GO) + $(GO) install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_GEN_GO_GRPC) + generate_proto_js: npm install grpc-tools protoc -I rpc/proto rpc/proto/gorush.proto --js_out=import_style=commonjs,binary:rpc/example/node/ --grpc_out=rpc/example/node/ --plugin=protoc-gen-grpc="node_modules/.bin/grpc_tools_node_protoc_plugin" diff --git a/rpc/proto/gorush.pb.go b/rpc/proto/gorush.pb.go index bf1cfac..bd08feb 100644 --- a/rpc/proto/gorush.pb.go +++ b/rpc/proto/gorush.pb.go @@ -1,18 +1,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.27.1 -// protoc v3.17.3 +// protoc-gen-go v1.28.1 +// protoc v3.21.5 // source: gorush.proto package proto import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" structpb "google.golang.org/protobuf/types/known/structpb" + reflect "reflect" + sync "sync" ) const ( @@ -662,21 +661,18 @@ func file_gorush_proto_rawDescGZIP() []byte { return file_gorush_proto_rawDescData } -var ( - file_gorush_proto_enumTypes = make([]protoimpl.EnumInfo, 2) - file_gorush_proto_msgTypes = make([]protoimpl.MessageInfo, 5) - file_gorush_proto_goTypes = []interface{}{ - (NotificationRequest_Priority)(0), // 0: proto.NotificationRequest.Priority - (HealthCheckResponse_ServingStatus)(0), // 1: proto.HealthCheckResponse.ServingStatus - (*Alert)(nil), // 2: proto.Alert - (*NotificationRequest)(nil), // 3: proto.NotificationRequest - (*NotificationReply)(nil), // 4: proto.NotificationReply - (*HealthCheckRequest)(nil), // 5: proto.HealthCheckRequest - (*HealthCheckResponse)(nil), // 6: proto.HealthCheckResponse - (*structpb.Struct)(nil), // 7: google.protobuf.Struct - } -) - +var file_gorush_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_gorush_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_gorush_proto_goTypes = []interface{}{ + (NotificationRequest_Priority)(0), // 0: proto.NotificationRequest.Priority + (HealthCheckResponse_ServingStatus)(0), // 1: proto.HealthCheckResponse.ServingStatus + (*Alert)(nil), // 2: proto.Alert + (*NotificationRequest)(nil), // 3: proto.NotificationRequest + (*NotificationReply)(nil), // 4: proto.NotificationReply + (*HealthCheckRequest)(nil), // 5: proto.HealthCheckRequest + (*HealthCheckResponse)(nil), // 6: proto.HealthCheckResponse + (*structpb.Struct)(nil), // 7: google.protobuf.Struct +} var file_gorush_proto_depIdxs = []int32{ 2, // 0: proto.NotificationRequest.alert:type_name -> proto.Alert 7, // 1: proto.NotificationRequest.data:type_name -> google.protobuf.Struct diff --git a/rpc/proto/gorush.proto b/rpc/proto/gorush.proto index b868155..81c1455 100644 --- a/rpc/proto/gorush.proto +++ b/rpc/proto/gorush.proto @@ -2,8 +2,7 @@ syntax = "proto3"; import "google/protobuf/struct.proto"; package proto; - -// option go_package = "./;proto"; +option go_package = "./;proto"; message Alert { string title = 1; diff --git a/rpc/proto/gorush_grpc.pb.go b/rpc/proto/gorush_grpc.pb.go index 767f798..135c58d 100644 --- a/rpc/proto/gorush_grpc.pb.go +++ b/rpc/proto/gorush_grpc.pb.go @@ -1,10 +1,13 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.5 +// source: gorush.proto package proto import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -47,7 +50,8 @@ type GorushServer interface { } // UnimplementedGorushServer should be embedded to have forward compatible implementations. -type UnimplementedGorushServer struct{} +type UnimplementedGorushServer struct { +} func (UnimplementedGorushServer) Send(context.Context, *NotificationRequest) (*NotificationReply, error) { return nil, status.Errorf(codes.Unimplemented, "method Send not implemented") @@ -130,7 +134,8 @@ type HealthServer interface { } // UnimplementedHealthServer should be embedded to have forward compatible implementations. -type UnimplementedHealthServer struct{} +type UnimplementedHealthServer struct { +} func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")