feat(grpc): initial grpc server. (#253)
* feat(grpc): initial grpc server. * refactor(vendor): add missing vendor. * fix testing Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
212
rpc/proto/gorush.pb.go
Normal file
212
rpc/proto/gorush.pb.go
Normal file
@@ -0,0 +1,212 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: gorush.proto
|
||||
|
||||
/*
|
||||
Package proto is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
gorush.proto
|
||||
|
||||
It has these top-level messages:
|
||||
NotificationRequest
|
||||
NotificationReply
|
||||
*/
|
||||
package proto
|
||||
|
||||
import proto1 "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto1.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type NotificationRequest struct {
|
||||
Tokens []string `protobuf:"bytes,1,rep,name=tokens" json:"tokens,omitempty"`
|
||||
Platform int32 `protobuf:"varint,2,opt,name=platform" json:"platform,omitempty"`
|
||||
Message string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"`
|
||||
Title string `protobuf:"bytes,4,opt,name=title" json:"title,omitempty"`
|
||||
Topic string `protobuf:"bytes,5,opt,name=topic" json:"topic,omitempty"`
|
||||
Key string `protobuf:"bytes,6,opt,name=key" json:"key,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NotificationRequest) Reset() { *m = NotificationRequest{} }
|
||||
func (m *NotificationRequest) String() string { return proto1.CompactTextString(m) }
|
||||
func (*NotificationRequest) ProtoMessage() {}
|
||||
func (*NotificationRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func (m *NotificationRequest) GetTokens() []string {
|
||||
if m != nil {
|
||||
return m.Tokens
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *NotificationRequest) GetPlatform() int32 {
|
||||
if m != nil {
|
||||
return m.Platform
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *NotificationRequest) GetMessage() string {
|
||||
if m != nil {
|
||||
return m.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *NotificationRequest) GetTitle() string {
|
||||
if m != nil {
|
||||
return m.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *NotificationRequest) GetTopic() string {
|
||||
if m != nil {
|
||||
return m.Topic
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *NotificationRequest) GetKey() string {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type NotificationReply struct {
|
||||
Success bool `protobuf:"varint,1,opt,name=success" json:"success,omitempty"`
|
||||
Counts int32 `protobuf:"varint,2,opt,name=counts" json:"counts,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NotificationReply) Reset() { *m = NotificationReply{} }
|
||||
func (m *NotificationReply) String() string { return proto1.CompactTextString(m) }
|
||||
func (*NotificationReply) ProtoMessage() {}
|
||||
func (*NotificationReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
|
||||
func (m *NotificationReply) GetSuccess() bool {
|
||||
if m != nil {
|
||||
return m.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *NotificationReply) GetCounts() int32 {
|
||||
if m != nil {
|
||||
return m.Counts
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto1.RegisterType((*NotificationRequest)(nil), "proto.NotificationRequest")
|
||||
proto1.RegisterType((*NotificationReply)(nil), "proto.NotificationReply")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// 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.SupportPackageIsVersion4
|
||||
|
||||
// Client API for Gorush service
|
||||
|
||||
type GorushClient interface {
|
||||
Send(ctx context.Context, in *NotificationRequest, opts ...grpc.CallOption) (*NotificationReply, error)
|
||||
}
|
||||
|
||||
type gorushClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewGorushClient(cc *grpc.ClientConn) GorushClient {
|
||||
return &gorushClient{cc}
|
||||
}
|
||||
|
||||
func (c *gorushClient) Send(ctx context.Context, in *NotificationRequest, opts ...grpc.CallOption) (*NotificationReply, error) {
|
||||
out := new(NotificationReply)
|
||||
err := grpc.Invoke(ctx, "/proto.Gorush/Send", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Gorush service
|
||||
|
||||
type GorushServer interface {
|
||||
Send(context.Context, *NotificationRequest) (*NotificationReply, error)
|
||||
}
|
||||
|
||||
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",
|
||||
}
|
||||
|
||||
func init() { proto1.RegisterFile("gorush.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 231 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0x86, 0x31, 0x69, 0x42, 0x7b, 0x62, 0x00, 0x83, 0x90, 0x95, 0x29, 0xca, 0x94, 0xa9, 0x03,
|
||||
0xec, 0x6c, 0x08, 0x26, 0x06, 0xf3, 0x04, 0xc1, 0x5c, 0x8b, 0xd5, 0x34, 0x67, 0x72, 0x97, 0x21,
|
||||
0x8f, 0xc3, 0x9b, 0x22, 0xbb, 0x29, 0x52, 0xa5, 0x4e, 0xf6, 0xf7, 0xff, 0xc3, 0x7d, 0xfa, 0xe1,
|
||||
0x7a, 0x4b, 0xc3, 0xc8, 0xdf, 0xeb, 0x30, 0x90, 0x90, 0xce, 0xd3, 0x53, 0xff, 0x2a, 0xb8, 0x7b,
|
||||
0x27, 0xf1, 0x1b, 0xef, 0x5a, 0xf1, 0xd4, 0x5b, 0xfc, 0x19, 0x91, 0x45, 0x3f, 0x40, 0x21, 0xb4,
|
||||
0xc3, 0x9e, 0x8d, 0xaa, 0xb2, 0x66, 0x65, 0x67, 0xd2, 0x25, 0x2c, 0x43, 0xd7, 0xca, 0x86, 0x86,
|
||||
0xbd, 0xb9, 0xac, 0x54, 0x93, 0xdb, 0x7f, 0xd6, 0x06, 0xae, 0xf6, 0xc8, 0xdc, 0x6e, 0xd1, 0x64,
|
||||
0x95, 0x6a, 0x56, 0xf6, 0x88, 0xfa, 0x1e, 0x72, 0xf1, 0xd2, 0xa1, 0x59, 0xa4, 0xfc, 0x00, 0x29,
|
||||
0xa5, 0xe0, 0x9d, 0xc9, 0xe7, 0x34, 0x82, 0xbe, 0x81, 0x6c, 0x87, 0x93, 0x29, 0x52, 0x16, 0xbf,
|
||||
0xf5, 0x0b, 0xdc, 0x9e, 0x2a, 0x86, 0x6e, 0x8a, 0xc7, 0x78, 0x74, 0x0e, 0x39, 0x1a, 0xaa, 0x66,
|
||||
0x69, 0x8f, 0x18, 0xd5, 0x1d, 0x8d, 0xbd, 0xf0, 0x2c, 0x38, 0xd3, 0xe3, 0x1b, 0x14, 0xaf, 0x69,
|
||||
0x01, 0xfd, 0x0c, 0x8b, 0x0f, 0xec, 0xbf, 0x74, 0x79, 0xd8, 0x62, 0x7d, 0x66, 0x80, 0xd2, 0x9c,
|
||||
0xed, 0x42, 0x37, 0xd5, 0x17, 0x9f, 0x45, 0xaa, 0x9e, 0xfe, 0x02, 0x00, 0x00, 0xff, 0xff, 0x52,
|
||||
0x8a, 0x53, 0x9a, 0x52, 0x01, 0x00, 0x00,
|
||||
}
|
||||
22
rpc/proto/gorush.proto
Normal file
22
rpc/proto/gorush.proto
Normal file
@@ -0,0 +1,22 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package proto;
|
||||
|
||||
message NotificationRequest {
|
||||
repeated string tokens = 1;
|
||||
int32 platform = 2;
|
||||
string message = 3;
|
||||
string title = 4;
|
||||
string topic = 5;
|
||||
string key = 6;
|
||||
}
|
||||
|
||||
message NotificationReply {
|
||||
bool success = 1;
|
||||
int32 counts = 2;
|
||||
}
|
||||
|
||||
service Gorush {
|
||||
rpc Send (NotificationRequest) returns (NotificationReply) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user