From 9d47494585d5b58fc838c3f78b792c54c1707e26 Mon Sep 17 00:00:00 2001 From: Romanenko Aleksei Date: Sun, 24 Oct 2021 20:34:46 -0500 Subject: [PATCH] fix #560: fix proto file and Makefile to generate pb (go, js) (#636) --- Makefile | 15 +- README.md | 4 +- rpc/example/go/send/main.go | 2 +- rpc/example/node/gorush_pb.js | 30 ++-- rpc/proto/gorush.pb.go | 316 +++++++++------------------------- rpc/proto/gorush.proto | 6 +- rpc/proto/gorush_grpc.pb.go | 182 ++++++++++++++++++++ 7 files changed, 288 insertions(+), 267 deletions(-) create mode 100644 rpc/proto/gorush_grpc.pb.go diff --git a/Makefile b/Makefile index ad9fb96..abed818 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ ARCHS ?= amd64 GOFILES := $(shell find . -name "*.go" -type f) TAGS ?= sqlite LDFLAGS ?= -X 'main.Version=$(VERSION)' -NODE_PROTOC_PLUGIN := $(shell which grpc_tools_node_protoc_plugin) ifneq ($(shell uname), Darwin) EXTLDFLAGS = -extldflags "-static" $(null) @@ -149,16 +148,14 @@ clean: find . -name *.db -delete -rm -rf release dist .cover -rpc/example/node/gorush_*_pb.js: rpc/proto/gorush.proto - @hash grpc_tools_node_protoc_plugin > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - npm install -g grpc-tools; \ - fi - 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_PROTOC_PLUGIN) +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" -rpc/proto/gorush.pb.go: rpc/proto/gorush.proto - protoc -I rpc/proto rpc/proto/gorush.proto --go_out=plugins=grpc:rpc/proto +generate_proto_go: + protoc -I rpc/proto rpc/proto/gorush.proto --go_out=rpc/proto --go-grpc_out=require_unimplemented_servers=false:rpc/proto -generate_proto: rpc/proto/gorush.pb.go rpc/example/node/gorush_*_pb.js +generate_proto: generate_proto_go generate_proto_js version: @echo $(VERSION) diff --git a/README.md b/README.md index 77299e5..6b3b9f2 100644 --- a/README.md +++ b/README.md @@ -1051,7 +1051,7 @@ func main() { Badge: 1, Category: "test", Sound: "test", - Priority: proto.Priority_High, + Priority: proto.NotificationRequest_HIGH, Alert: &proto.Alert{ Title: "Test Title", Body: "Test Alert Body", @@ -1156,7 +1156,7 @@ func main() { Badge: 1, Category: "test", Sound: "test", - Priority: proto.Priority_High, + Priority: proto.NotificationRequest_HIGH, Alert: &proto.Alert{ Title: "Test Title", Body: "Test Alert Body", diff --git a/rpc/example/go/send/main.go b/rpc/example/go/send/main.go index 8cf2995..f9b0581 100644 --- a/rpc/example/go/send/main.go +++ b/rpc/example/go/send/main.go @@ -30,7 +30,7 @@ func main() { Badge: 1, Category: "test", Sound: "test", - Priority: proto.Priority_High, + Priority: proto.NotificationRequest_HIGH, Alert: &proto.Alert{ Title: "Test Title", Body: "Test Alert Body", diff --git a/rpc/example/node/gorush_pb.js b/rpc/example/node/gorush_pb.js index 32aa1b7..bf5d084 100644 --- a/rpc/example/node/gorush_pb.js +++ b/rpc/example/node/gorush_pb.js @@ -7,6 +7,8 @@ * @public */ // GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck var jspb = require('google-protobuf'); var goog = jspb; @@ -20,7 +22,7 @@ goog.exportSymbol('proto.proto.HealthCheckResponse', null, global); goog.exportSymbol('proto.proto.HealthCheckResponse.ServingStatus', null, global); goog.exportSymbol('proto.proto.NotificationReply', null, global); goog.exportSymbol('proto.proto.NotificationRequest', null, global); -goog.exportSymbol('proto.proto.Priority', null, global); +goog.exportSymbol('proto.proto.NotificationRequest.Priority', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -725,7 +727,7 @@ proto.proto.NotificationRequest.deserializeBinaryFromReader = function(msg, read msg.setImage(value); break; case 16: - var value = /** @type {!proto.proto.Priority} */ (reader.readEnum()); + var value = /** @type {!proto.proto.NotificationRequest.Priority} */ (reader.readEnum()); msg.setPriority(value); break; default: @@ -874,6 +876,14 @@ proto.proto.NotificationRequest.serializeBinaryToWriter = function(message, writ }; +/** + * @enum {number} + */ +proto.proto.NotificationRequest.Priority = { + NORMAL: 0, + HIGH: 1 +}; + /** * repeated string tokens = 1; * @return {!Array} @@ -1202,16 +1212,16 @@ proto.proto.NotificationRequest.prototype.setImage = function(value) { /** - * optional Priority Priority = 16; - * @return {!proto.proto.Priority} + * optional Priority priority = 16; + * @return {!proto.proto.NotificationRequest.Priority} */ proto.proto.NotificationRequest.prototype.getPriority = function() { - return /** @type {!proto.proto.Priority} */ (jspb.Message.getFieldWithDefault(this, 16, 0)); + return /** @type {!proto.proto.NotificationRequest.Priority} */ (jspb.Message.getFieldWithDefault(this, 16, 0)); }; /** - * @param {!proto.proto.Priority} value + * @param {!proto.proto.NotificationRequest.Priority} value * @return {!proto.proto.NotificationRequest} returns this */ proto.proto.NotificationRequest.prototype.setPriority = function(value) { @@ -1648,12 +1658,4 @@ proto.proto.HealthCheckResponse.prototype.setStatus = function(value) { }; -/** - * @enum {number} - */ -proto.proto.Priority = { - NORMAL: 0, - HIGH: 1 -}; - goog.object.extend(exports, proto.proto); diff --git a/rpc/proto/gorush.pb.go b/rpc/proto/gorush.pb.go index 24392f1..e22570f 100644 --- a/rpc/proto/gorush.pb.go +++ b/rpc/proto/gorush.pb.go @@ -1,23 +1,18 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.24.0 -// protoc v3.12.3 +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 // source: gorush.proto package proto import ( - context "context" reflect "reflect" sync "sync" - proto "github.com/golang/protobuf/proto" - _struct "github.com/golang/protobuf/ptypes/struct" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" ) const ( @@ -27,54 +22,50 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type Priority int32 +type NotificationRequest_Priority int32 const ( - Priority_Normal Priority = 0 - Priority_High Priority = 1 + NotificationRequest_NORMAL NotificationRequest_Priority = 0 + NotificationRequest_HIGH NotificationRequest_Priority = 1 ) -// Enum value maps for Priority. +// Enum value maps for NotificationRequest_Priority. var ( - Priority_name = map[int32]string{ - 0: "Normal", - 1: "High", + NotificationRequest_Priority_name = map[int32]string{ + 0: "NORMAL", + 1: "HIGH", } - Priority_value = map[string]int32{ - "Normal": 0, - "High": 1, + NotificationRequest_Priority_value = map[string]int32{ + "NORMAL": 0, + "HIGH": 1, } ) -func (x Priority) Enum() *Priority { - p := new(Priority) +func (x NotificationRequest_Priority) Enum() *NotificationRequest_Priority { + p := new(NotificationRequest_Priority) *p = x return p } -func (x Priority) String() string { +func (x NotificationRequest_Priority) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (Priority) Descriptor() protoreflect.EnumDescriptor { +func (NotificationRequest_Priority) Descriptor() protoreflect.EnumDescriptor { return file_gorush_proto_enumTypes[0].Descriptor() } -func (Priority) Type() protoreflect.EnumType { +func (NotificationRequest_Priority) Type() protoreflect.EnumType { return &file_gorush_proto_enumTypes[0] } -func (x Priority) Number() protoreflect.EnumNumber { +func (x NotificationRequest_Priority) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use Priority.Descriptor instead. -func (Priority) EnumDescriptor() ([]byte, []int) { - return file_gorush_proto_rawDescGZIP(), []int{0} +// Deprecated: Use NotificationRequest_Priority.Descriptor instead. +func (NotificationRequest_Priority) EnumDescriptor() ([]byte, []int) { + return file_gorush_proto_rawDescGZIP(), []int{1, 0} } type HealthCheckResponse_ServingStatus int32 @@ -250,22 +241,22 @@ type NotificationRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` - Platform int32 `protobuf:"varint,2,opt,name=platform,proto3" json:"platform,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` - Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"` - Topic string `protobuf:"bytes,5,opt,name=topic,proto3" json:"topic,omitempty"` - Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` - Badge int32 `protobuf:"varint,7,opt,name=badge,proto3" json:"badge,omitempty"` - Category string `protobuf:"bytes,8,opt,name=category,proto3" json:"category,omitempty"` - Alert *Alert `protobuf:"bytes,9,opt,name=alert,proto3" json:"alert,omitempty"` - Sound string `protobuf:"bytes,10,opt,name=sound,proto3" json:"sound,omitempty"` - ContentAvailable bool `protobuf:"varint,11,opt,name=contentAvailable,proto3" json:"contentAvailable,omitempty"` - ThreadID string `protobuf:"bytes,12,opt,name=threadID,proto3" json:"threadID,omitempty"` - MutableContent bool `protobuf:"varint,13,opt,name=mutableContent,proto3" json:"mutableContent,omitempty"` - Data *_struct.Struct `protobuf:"bytes,14,opt,name=data,proto3" json:"data,omitempty"` - Image string `protobuf:"bytes,15,opt,name=image,proto3" json:"image,omitempty"` - Priority Priority `protobuf:"varint,16,opt,name=Priority,proto3,enum=proto.Priority" json:"Priority,omitempty"` + Tokens []string `protobuf:"bytes,1,rep,name=tokens,proto3" json:"tokens,omitempty"` + Platform int32 `protobuf:"varint,2,opt,name=platform,proto3" json:"platform,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"` + Topic string `protobuf:"bytes,5,opt,name=topic,proto3" json:"topic,omitempty"` + Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` + Badge int32 `protobuf:"varint,7,opt,name=badge,proto3" json:"badge,omitempty"` + Category string `protobuf:"bytes,8,opt,name=category,proto3" json:"category,omitempty"` + Alert *Alert `protobuf:"bytes,9,opt,name=alert,proto3" json:"alert,omitempty"` + Sound string `protobuf:"bytes,10,opt,name=sound,proto3" json:"sound,omitempty"` + ContentAvailable bool `protobuf:"varint,11,opt,name=contentAvailable,proto3" json:"contentAvailable,omitempty"` + ThreadID string `protobuf:"bytes,12,opt,name=threadID,proto3" json:"threadID,omitempty"` + MutableContent bool `protobuf:"varint,13,opt,name=mutableContent,proto3" json:"mutableContent,omitempty"` + Data *structpb.Struct `protobuf:"bytes,14,opt,name=data,proto3" json:"data,omitempty"` + Image string `protobuf:"bytes,15,opt,name=image,proto3" json:"image,omitempty"` + Priority NotificationRequest_Priority `protobuf:"varint,16,opt,name=priority,proto3,enum=proto.NotificationRequest_Priority" json:"priority,omitempty"` } func (x *NotificationRequest) Reset() { @@ -391,7 +382,7 @@ func (x *NotificationRequest) GetMutableContent() bool { return false } -func (x *NotificationRequest) GetData() *_struct.Struct { +func (x *NotificationRequest) GetData() *structpb.Struct { if x != nil { return x.Data } @@ -405,11 +396,11 @@ func (x *NotificationRequest) GetImage() string { return "" } -func (x *NotificationRequest) GetPriority() Priority { +func (x *NotificationRequest) GetPriority() NotificationRequest_Priority { if x != nil { return x.Priority } - return Priority_Normal + return NotificationRequest_NORMAL } type NotificationReply struct { @@ -585,7 +576,7 @@ var file_gorush_proto_rawDesc = []byte{ 0x6f, 0x63, 0x41, 0x72, 0x67, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x6f, 0x63, 0x41, 0x72, 0x67, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x4c, 0x6f, 0x63, 0x41, 0x72, 0x67, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x69, 0x74, - 0x6c, 0x65, 0x4c, 0x6f, 0x63, 0x41, 0x72, 0x67, 0x73, 0x22, 0xed, 0x03, 0x0a, 0x13, 0x4e, 0x6f, + 0x6c, 0x65, 0x4c, 0x6f, 0x63, 0x41, 0x72, 0x67, 0x73, 0x22, 0xa3, 0x04, 0x0a, 0x13, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, @@ -613,39 +604,40 @@ var file_gorush_proto_rawDesc = []byte{ 0x61, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, - 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x08, - 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x52, - 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x45, 0x0a, 0x11, 0x4e, 0x6f, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x22, 0x2e, 0x0a, 0x12, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x22, 0x93, 0x01, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x28, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x3a, 0x0a, 0x0d, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x45, 0x52, 0x56, - 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x52, - 0x56, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x2a, 0x20, 0x0a, 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, - 0x74, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x10, 0x00, 0x12, 0x08, - 0x0a, 0x04, 0x48, 0x69, 0x67, 0x68, 0x10, 0x01, 0x32, 0x48, 0x0a, 0x06, 0x47, 0x6f, 0x72, 0x75, - 0x73, 0x68, 0x12, 0x3e, 0x0a, 0x04, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, + 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x3f, 0x0a, 0x08, + 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, + 0x69, 0x74, 0x79, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x20, 0x0a, + 0x08, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, + 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x49, 0x47, 0x48, 0x10, 0x01, 0x22, + 0x45, 0x0a, 0x11, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x16, + 0x0a, 0x06, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x22, 0x2e, 0x0a, 0x12, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, + 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x28, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x22, 0x3a, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, + 0x0a, 0x07, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, + 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x32, 0x48, 0x0a, 0x06, + 0x47, 0x6f, 0x72, 0x75, 0x73, 0x68, 0x12, 0x3e, 0x0a, 0x04, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x1a, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, - 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, - 0x22, 0x00, 0x32, 0x48, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x3e, 0x0a, 0x05, - 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, - 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x32, 0x48, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x12, 0x3e, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -664,21 +656,21 @@ var ( file_gorush_proto_enumTypes = make([]protoimpl.EnumInfo, 2) file_gorush_proto_msgTypes = make([]protoimpl.MessageInfo, 5) file_gorush_proto_goTypes = []interface{}{ - (Priority)(0), // 0: proto.Priority + (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 - (*_struct.Struct)(nil), // 7: google.protobuf.Struct + (*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 - 0, // 2: proto.NotificationRequest.Priority:type_name -> proto.Priority + 0, // 2: proto.NotificationRequest.priority:type_name -> proto.NotificationRequest.Priority 1, // 3: proto.HealthCheckResponse.status:type_name -> proto.HealthCheckResponse.ServingStatus 3, // 4: proto.Gorush.Send:input_type -> proto.NotificationRequest 5, // 5: proto.Health.Check:input_type -> proto.HealthCheckRequest @@ -778,155 +770,3 @@ func file_gorush_proto_init() { file_gorush_proto_goTypes = nil file_gorush_proto_depIdxs = nil } - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ context.Context - _ grpc.ClientConnInterface -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// GorushClient is the client API for Gorush service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GorushClient interface { - Send(ctx context.Context, in *NotificationRequest, opts ...grpc.CallOption) (*NotificationReply, error) -} - -type gorushClient struct { - cc grpc.ClientConnInterface -} - -func NewGorushClient(cc grpc.ClientConnInterface) GorushClient { - return &gorushClient{cc} -} - -func (c *gorushClient) Send(ctx context.Context, in *NotificationRequest, opts ...grpc.CallOption) (*NotificationReply, error) { - out := new(NotificationReply) - err := c.cc.Invoke(ctx, "/proto.Gorush/Send", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GorushServer is the server API for Gorush service. -type GorushServer interface { - Send(context.Context, *NotificationRequest) (*NotificationReply, error) -} - -// UnimplementedGorushServer can be embedded to have forward compatible implementations. -type UnimplementedGorushServer struct{} - -func (*UnimplementedGorushServer) Send(context.Context, *NotificationRequest) (*NotificationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method Send not implemented") -} - -func RegisterGorushServer(s *grpc.Server, srv GorushServer) { - s.RegisterService(&_Gorush_serviceDesc, srv) -} - -func _Gorush_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(NotificationRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GorushServer).Send(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Gorush/Send", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GorushServer).Send(ctx, req.(*NotificationRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Gorush_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.Gorush", - HandlerType: (*GorushServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Send", - Handler: _Gorush_Send_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "gorush.proto", -} - -// HealthClient is the client API for Health service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type HealthClient interface { - Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) -} - -type healthClient struct { - cc grpc.ClientConnInterface -} - -func NewHealthClient(cc grpc.ClientConnInterface) HealthClient { - return &healthClient{cc} -} - -func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) { - out := new(HealthCheckResponse) - err := c.cc.Invoke(ctx, "/proto.Health/Check", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// HealthServer is the server API for Health service. -type HealthServer interface { - Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) -} - -// UnimplementedHealthServer can be embedded to have forward compatible implementations. -type UnimplementedHealthServer struct{} - -func (*UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") -} - -func RegisterHealthServer(s *grpc.Server, srv HealthServer) { - s.RegisterService(&_Health_serviceDesc, srv) -} - -func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HealthCheckRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(HealthServer).Check(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Health/Check", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Health_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.Health", - HandlerType: (*HealthServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Check", - Handler: _Health_Check_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "gorush.proto", -} diff --git a/rpc/proto/gorush.proto b/rpc/proto/gorush.proto index 25238c7..7181c66 100644 --- a/rpc/proto/gorush.proto +++ b/rpc/proto/gorush.proto @@ -33,10 +33,10 @@ message NotificationRequest { google.protobuf.Struct data = 14; string image = 15; enum Priority { - Normal = 0; - High = 1; + NORMAL = 0; + HIGH = 1; } - Priority Priority = 16; + Priority priority = 16; } message NotificationReply { diff --git a/rpc/proto/gorush_grpc.pb.go b/rpc/proto/gorush_grpc.pb.go new file mode 100644 index 0000000..767f798 --- /dev/null +++ b/rpc/proto/gorush_grpc.pb.go @@ -0,0 +1,182 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package proto + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// GorushClient is the client API for Gorush service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type GorushClient interface { + Send(ctx context.Context, in *NotificationRequest, opts ...grpc.CallOption) (*NotificationReply, error) +} + +type gorushClient struct { + cc grpc.ClientConnInterface +} + +func NewGorushClient(cc grpc.ClientConnInterface) GorushClient { + return &gorushClient{cc} +} + +func (c *gorushClient) Send(ctx context.Context, in *NotificationRequest, opts ...grpc.CallOption) (*NotificationReply, error) { + out := new(NotificationReply) + err := c.cc.Invoke(ctx, "/proto.Gorush/Send", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GorushServer is the server API for Gorush service. +// All implementations should embed UnimplementedGorushServer +// for forward compatibility +type GorushServer interface { + Send(context.Context, *NotificationRequest) (*NotificationReply, error) +} + +// UnimplementedGorushServer should be embedded to have forward compatible implementations. +type UnimplementedGorushServer struct{} + +func (UnimplementedGorushServer) Send(context.Context, *NotificationRequest) (*NotificationReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Send not implemented") +} + +// UnsafeGorushServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GorushServer will +// result in compilation errors. +type UnsafeGorushServer interface { + mustEmbedUnimplementedGorushServer() +} + +func RegisterGorushServer(s grpc.ServiceRegistrar, srv GorushServer) { + s.RegisterService(&Gorush_ServiceDesc, srv) +} + +func _Gorush_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NotificationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GorushServer).Send(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Gorush/Send", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GorushServer).Send(ctx, req.(*NotificationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Gorush_ServiceDesc is the grpc.ServiceDesc for Gorush service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Gorush_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.Gorush", + HandlerType: (*GorushServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Send", + Handler: _Gorush_Send_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "gorush.proto", +} + +// HealthClient is the client API for Health service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type HealthClient interface { + Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) +} + +type healthClient struct { + cc grpc.ClientConnInterface +} + +func NewHealthClient(cc grpc.ClientConnInterface) HealthClient { + return &healthClient{cc} +} + +func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) { + out := new(HealthCheckResponse) + err := c.cc.Invoke(ctx, "/proto.Health/Check", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// HealthServer is the server API for Health service. +// All implementations should embed UnimplementedHealthServer +// for forward compatibility +type HealthServer interface { + Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) +} + +// UnimplementedHealthServer should be embedded to have forward compatible implementations. +type UnimplementedHealthServer struct{} + +func (UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") +} + +// UnsafeHealthServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to HealthServer will +// result in compilation errors. +type UnsafeHealthServer interface { + mustEmbedUnimplementedHealthServer() +} + +func RegisterHealthServer(s grpc.ServiceRegistrar, srv HealthServer) { + s.RegisterService(&Health_ServiceDesc, srv) +} + +func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HealthCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HealthServer).Check(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Health/Check", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Health_ServiceDesc is the grpc.ServiceDesc for Health service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Health_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.Health", + HandlerType: (*HealthServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Check", + Handler: _Health_Check_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "gorush.proto", +}