refactor(gRPC): update go proto file

This commit is contained in:
Bo-Yi Wu 2022-11-09 14:18:51 +08:00
parent e13a05bc08
commit 8b4424c518
4 changed files with 33 additions and 25 deletions

View File

@ -12,6 +12,9 @@ GOFILES := $(shell find . -name "*.go" -type f)
TAGS ?= sqlite TAGS ?= sqlite
LDFLAGS ?= -X 'main.Version=$(VERSION)' LDFLAGS ?= -X 'main.Version=$(VERSION)'
PROTOC_GEN_GO=v1.28
PROTOC_GEN_GO_GRPC=v1.2
ifneq ($(shell uname), Darwin) ifneq ($(shell uname), Darwin)
EXTLDFLAGS = -extldflags "-static" $(null) EXTLDFLAGS = -extldflags "-static" $(null)
else else
@ -163,6 +166,11 @@ clean:
find . -name *.db -delete find . -name *.db -delete
-rm -rf release dist .cover -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: generate_proto_js:
npm install grpc-tools 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" 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"

View File

@ -1,18 +1,17 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.27.1 // protoc-gen-go v1.28.1
// protoc v3.17.3 // protoc v3.21.5
// source: gorush.proto // source: gorush.proto
package proto package proto
import ( import (
reflect "reflect"
sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
structpb "google.golang.org/protobuf/types/known/structpb" structpb "google.golang.org/protobuf/types/known/structpb"
reflect "reflect"
sync "sync"
) )
const ( const (
@ -662,21 +661,18 @@ func file_gorush_proto_rawDescGZIP() []byte {
return file_gorush_proto_rawDescData return file_gorush_proto_rawDescData
} }
var ( var file_gorush_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
file_gorush_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_gorush_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
file_gorush_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_gorush_proto_goTypes = []interface{}{
file_gorush_proto_goTypes = []interface{}{ (NotificationRequest_Priority)(0), // 0: proto.NotificationRequest.Priority
(NotificationRequest_Priority)(0), // 0: proto.NotificationRequest.Priority (HealthCheckResponse_ServingStatus)(0), // 1: proto.HealthCheckResponse.ServingStatus
(HealthCheckResponse_ServingStatus)(0), // 1: proto.HealthCheckResponse.ServingStatus (*Alert)(nil), // 2: proto.Alert
(*Alert)(nil), // 2: proto.Alert (*NotificationRequest)(nil), // 3: proto.NotificationRequest
(*NotificationRequest)(nil), // 3: proto.NotificationRequest (*NotificationReply)(nil), // 4: proto.NotificationReply
(*NotificationReply)(nil), // 4: proto.NotificationReply (*HealthCheckRequest)(nil), // 5: proto.HealthCheckRequest
(*HealthCheckRequest)(nil), // 5: proto.HealthCheckRequest (*HealthCheckResponse)(nil), // 6: proto.HealthCheckResponse
(*HealthCheckResponse)(nil), // 6: proto.HealthCheckResponse (*structpb.Struct)(nil), // 7: google.protobuf.Struct
(*structpb.Struct)(nil), // 7: google.protobuf.Struct }
}
)
var file_gorush_proto_depIdxs = []int32{ var file_gorush_proto_depIdxs = []int32{
2, // 0: proto.NotificationRequest.alert:type_name -> proto.Alert 2, // 0: proto.NotificationRequest.alert:type_name -> proto.Alert
7, // 1: proto.NotificationRequest.data:type_name -> google.protobuf.Struct 7, // 1: proto.NotificationRequest.data:type_name -> google.protobuf.Struct

View File

@ -2,8 +2,7 @@ syntax = "proto3";
import "google/protobuf/struct.proto"; import "google/protobuf/struct.proto";
package proto; package proto;
option go_package = "./;proto";
// option go_package = "./;proto";
message Alert { message Alert {
string title = 1; string title = 1;

View File

@ -1,10 +1,13 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT. // 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 package proto
import ( import (
context "context" context "context"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
@ -47,7 +50,8 @@ type GorushServer interface {
} }
// UnimplementedGorushServer should be embedded to have forward compatible implementations. // UnimplementedGorushServer should be embedded to have forward compatible implementations.
type UnimplementedGorushServer struct{} type UnimplementedGorushServer struct {
}
func (UnimplementedGorushServer) Send(context.Context, *NotificationRequest) (*NotificationReply, error) { func (UnimplementedGorushServer) Send(context.Context, *NotificationRequest) (*NotificationReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Send not implemented") 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. // UnimplementedHealthServer should be embedded to have forward compatible implementations.
type UnimplementedHealthServer struct{} type UnimplementedHealthServer struct {
}
func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")