test
This commit is contained in:
parent
23f6a0e3f4
commit
a9cd891a8c
6
echoserver/Makefile
Normal file
6
echoserver/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
all:
|
||||||
|
protoc -I/usr/local/include -I. \
|
||||||
|
-I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
|
||||||
|
--go_out=plugins=grpc:. \
|
||||||
|
--grpc-gateway_out=logtostderr=true:. \
|
||||||
|
echoserver.proto
|
377
echoserver/echoserver.pb.go
Normal file
377
echoserver/echoserver.pb.go
Normal file
|
@ -0,0 +1,377 @@
|
||||||
|
// Code generated by protoc-gen-go.
|
||||||
|
// source: echoserver.proto
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package echoserver is a generated protocol buffer package.
|
||||||
|
|
||||||
|
It is generated from these files:
|
||||||
|
echoserver.proto
|
||||||
|
|
||||||
|
It has these top-level messages:
|
||||||
|
EchoRequest
|
||||||
|
EchoResponse
|
||||||
|
Heartbeat
|
||||||
|
Empty
|
||||||
|
*/
|
||||||
|
package echoserver
|
||||||
|
|
||||||
|
import proto "github.com/golang/protobuf/proto"
|
||||||
|
import fmt "fmt"
|
||||||
|
import math "math"
|
||||||
|
import _ "google.golang.org/genproto/googleapis/api/annotations"
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "golang.org/x/net/context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.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 _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
|
type Heartbeat_Status int32
|
||||||
|
|
||||||
|
const (
|
||||||
|
Heartbeat_UNKNOWN Heartbeat_Status = 0
|
||||||
|
Heartbeat_OK Heartbeat_Status = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
var Heartbeat_Status_name = map[int32]string{
|
||||||
|
0: "UNKNOWN",
|
||||||
|
1: "OK",
|
||||||
|
}
|
||||||
|
var Heartbeat_Status_value = map[string]int32{
|
||||||
|
"UNKNOWN": 0,
|
||||||
|
"OK": 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x Heartbeat_Status) String() string {
|
||||||
|
return proto.EnumName(Heartbeat_Status_name, int32(x))
|
||||||
|
}
|
||||||
|
func (Heartbeat_Status) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} }
|
||||||
|
|
||||||
|
type EchoRequest struct {
|
||||||
|
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EchoRequest) Reset() { *m = EchoRequest{} }
|
||||||
|
func (m *EchoRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EchoRequest) ProtoMessage() {}
|
||||||
|
func (*EchoRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
|
||||||
|
func (m *EchoRequest) GetMessage() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type EchoResponse struct {
|
||||||
|
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *EchoResponse) Reset() { *m = EchoResponse{} }
|
||||||
|
func (m *EchoResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*EchoResponse) ProtoMessage() {}
|
||||||
|
func (*EchoResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||||
|
|
||||||
|
func (m *EchoResponse) GetMessage() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Message
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type Heartbeat struct {
|
||||||
|
Status Heartbeat_Status `protobuf:"varint,1,opt,name=status,enum=echoserver.Heartbeat_Status" json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Heartbeat) Reset() { *m = Heartbeat{} }
|
||||||
|
func (m *Heartbeat) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Heartbeat) ProtoMessage() {}
|
||||||
|
func (*Heartbeat) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||||
|
|
||||||
|
func (m *Heartbeat) GetStatus() Heartbeat_Status {
|
||||||
|
if m != nil {
|
||||||
|
return m.Status
|
||||||
|
}
|
||||||
|
return Heartbeat_UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
|
type Empty struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Empty) Reset() { *m = Empty{} }
|
||||||
|
func (m *Empty) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Empty) ProtoMessage() {}
|
||||||
|
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*EchoRequest)(nil), "echoserver.EchoRequest")
|
||||||
|
proto.RegisterType((*EchoResponse)(nil), "echoserver.EchoResponse")
|
||||||
|
proto.RegisterType((*Heartbeat)(nil), "echoserver.Heartbeat")
|
||||||
|
proto.RegisterType((*Empty)(nil), "echoserver.Empty")
|
||||||
|
proto.RegisterEnum("echoserver.Heartbeat_Status", Heartbeat_Status_name, Heartbeat_Status_value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 EchoService service
|
||||||
|
|
||||||
|
type EchoServiceClient interface {
|
||||||
|
Echo(ctx context.Context, opts ...grpc.CallOption) (EchoService_EchoClient, error)
|
||||||
|
Stream(ctx context.Context, in *Empty, opts ...grpc.CallOption) (EchoService_StreamClient, error)
|
||||||
|
Heartbeats(ctx context.Context, opts ...grpc.CallOption) (EchoService_HeartbeatsClient, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type echoServiceClient struct {
|
||||||
|
cc *grpc.ClientConn
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewEchoServiceClient(cc *grpc.ClientConn) EchoServiceClient {
|
||||||
|
return &echoServiceClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *echoServiceClient) Echo(ctx context.Context, opts ...grpc.CallOption) (EchoService_EchoClient, error) {
|
||||||
|
stream, err := grpc.NewClientStream(ctx, &_EchoService_serviceDesc.Streams[0], c.cc, "/echoserver.EchoService/Echo", opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
x := &echoServiceEchoClient{stream}
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type EchoService_EchoClient interface {
|
||||||
|
Send(*EchoRequest) error
|
||||||
|
Recv() (*EchoResponse, error)
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type echoServiceEchoClient struct {
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceEchoClient) Send(m *EchoRequest) error {
|
||||||
|
return x.ClientStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceEchoClient) Recv() (*EchoResponse, error) {
|
||||||
|
m := new(EchoResponse)
|
||||||
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *echoServiceClient) Stream(ctx context.Context, in *Empty, opts ...grpc.CallOption) (EchoService_StreamClient, error) {
|
||||||
|
stream, err := grpc.NewClientStream(ctx, &_EchoService_serviceDesc.Streams[1], c.cc, "/echoserver.EchoService/Stream", opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
x := &echoServiceStreamClient{stream}
|
||||||
|
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := x.ClientStream.CloseSend(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type EchoService_StreamClient interface {
|
||||||
|
Recv() (*EchoResponse, error)
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type echoServiceStreamClient struct {
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceStreamClient) Recv() (*EchoResponse, error) {
|
||||||
|
m := new(EchoResponse)
|
||||||
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *echoServiceClient) Heartbeats(ctx context.Context, opts ...grpc.CallOption) (EchoService_HeartbeatsClient, error) {
|
||||||
|
stream, err := grpc.NewClientStream(ctx, &_EchoService_serviceDesc.Streams[2], c.cc, "/echoserver.EchoService/Heartbeats", opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
x := &echoServiceHeartbeatsClient{stream}
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type EchoService_HeartbeatsClient interface {
|
||||||
|
Send(*Empty) error
|
||||||
|
Recv() (*Heartbeat, error)
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type echoServiceHeartbeatsClient struct {
|
||||||
|
grpc.ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceHeartbeatsClient) Send(m *Empty) error {
|
||||||
|
return x.ClientStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceHeartbeatsClient) Recv() (*Heartbeat, error) {
|
||||||
|
m := new(Heartbeat)
|
||||||
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server API for EchoService service
|
||||||
|
|
||||||
|
type EchoServiceServer interface {
|
||||||
|
Echo(EchoService_EchoServer) error
|
||||||
|
Stream(*Empty, EchoService_StreamServer) error
|
||||||
|
Heartbeats(EchoService_HeartbeatsServer) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterEchoServiceServer(s *grpc.Server, srv EchoServiceServer) {
|
||||||
|
s.RegisterService(&_EchoService_serviceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _EchoService_Echo_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||||
|
return srv.(EchoServiceServer).Echo(&echoServiceEchoServer{stream})
|
||||||
|
}
|
||||||
|
|
||||||
|
type EchoService_EchoServer interface {
|
||||||
|
Send(*EchoResponse) error
|
||||||
|
Recv() (*EchoRequest, error)
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type echoServiceEchoServer struct {
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceEchoServer) Send(m *EchoResponse) error {
|
||||||
|
return x.ServerStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceEchoServer) Recv() (*EchoRequest, error) {
|
||||||
|
m := new(EchoRequest)
|
||||||
|
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _EchoService_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||||
|
m := new(Empty)
|
||||||
|
if err := stream.RecvMsg(m); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return srv.(EchoServiceServer).Stream(m, &echoServiceStreamServer{stream})
|
||||||
|
}
|
||||||
|
|
||||||
|
type EchoService_StreamServer interface {
|
||||||
|
Send(*EchoResponse) error
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type echoServiceStreamServer struct {
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceStreamServer) Send(m *EchoResponse) error {
|
||||||
|
return x.ServerStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _EchoService_Heartbeats_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||||
|
return srv.(EchoServiceServer).Heartbeats(&echoServiceHeartbeatsServer{stream})
|
||||||
|
}
|
||||||
|
|
||||||
|
type EchoService_HeartbeatsServer interface {
|
||||||
|
Send(*Heartbeat) error
|
||||||
|
Recv() (*Empty, error)
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
type echoServiceHeartbeatsServer struct {
|
||||||
|
grpc.ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceHeartbeatsServer) Send(m *Heartbeat) error {
|
||||||
|
return x.ServerStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *echoServiceHeartbeatsServer) Recv() (*Empty, error) {
|
||||||
|
m := new(Empty)
|
||||||
|
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var _EchoService_serviceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "echoserver.EchoService",
|
||||||
|
HandlerType: (*EchoServiceServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{},
|
||||||
|
Streams: []grpc.StreamDesc{
|
||||||
|
{
|
||||||
|
StreamName: "Echo",
|
||||||
|
Handler: _EchoService_Echo_Handler,
|
||||||
|
ServerStreams: true,
|
||||||
|
ClientStreams: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
StreamName: "Stream",
|
||||||
|
Handler: _EchoService_Stream_Handler,
|
||||||
|
ServerStreams: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
StreamName: "Heartbeats",
|
||||||
|
Handler: _EchoService_Heartbeats_Handler,
|
||||||
|
ServerStreams: true,
|
||||||
|
ClientStreams: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Metadata: "echoserver.proto",
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("echoserver.proto", fileDescriptor0) }
|
||||||
|
|
||||||
|
var fileDescriptor0 = []byte{
|
||||||
|
// 300 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x4a, 0xc3, 0x40,
|
||||||
|
0x10, 0x86, 0xdd, 0x62, 0x13, 0x3a, 0xb5, 0x12, 0x57, 0xc4, 0x50, 0x2a, 0xc8, 0x5e, 0x0c, 0x1e,
|
||||||
|
0x92, 0x52, 0x3d, 0x79, 0xaf, 0x08, 0x85, 0x04, 0x52, 0xc4, 0xab, 0xdb, 0x30, 0x24, 0x01, 0x93,
|
||||||
|
0x8d, 0xbb, 0xdb, 0x82, 0x57, 0x5f, 0xc1, 0x47, 0xf3, 0x15, 0x7c, 0x07, 0xaf, 0x92, 0xac, 0xc6,
|
||||||
|
0x88, 0xa5, 0xc7, 0x99, 0xfd, 0xe6, 0x9f, 0xff, 0xdf, 0x01, 0x07, 0x93, 0x4c, 0x28, 0x94, 0x1b,
|
||||||
|
0x94, 0x7e, 0x25, 0x85, 0x16, 0x14, 0x7e, 0x3b, 0xe3, 0x49, 0x2a, 0x44, 0xfa, 0x84, 0x01, 0xaf,
|
||||||
|
0xf2, 0x80, 0x97, 0xa5, 0xd0, 0x5c, 0xe7, 0xa2, 0x54, 0x86, 0x64, 0x17, 0x30, 0x9c, 0x27, 0x99,
|
||||||
|
0x88, 0xf1, 0x79, 0x8d, 0x4a, 0x53, 0x17, 0xec, 0x02, 0x95, 0xe2, 0x29, 0xba, 0xe4, 0x9c, 0x78,
|
||||||
|
0x83, 0xf8, 0xa7, 0x64, 0x1e, 0x1c, 0x18, 0x50, 0x55, 0xa2, 0x54, 0xb8, 0x83, 0x7c, 0x84, 0xc1,
|
||||||
|
0x1d, 0x72, 0xa9, 0x57, 0xc8, 0x35, 0xbd, 0x06, 0x4b, 0x69, 0xae, 0xd7, 0xaa, 0xa1, 0x0e, 0x67,
|
||||||
|
0x13, 0xbf, 0x63, 0xb6, 0xc5, 0xfc, 0x65, 0xc3, 0xc4, 0xdf, 0x2c, 0x3b, 0x03, 0xcb, 0x74, 0xe8,
|
||||||
|
0x10, 0xec, 0xfb, 0x70, 0x11, 0x46, 0x0f, 0xa1, 0xb3, 0x47, 0x2d, 0xe8, 0x45, 0x0b, 0x87, 0x30,
|
||||||
|
0x1b, 0xfa, 0xf3, 0xa2, 0xd2, 0x2f, 0xb3, 0x4f, 0x62, 0xec, 0x2f, 0x51, 0x6e, 0xf2, 0x04, 0x69,
|
||||||
|
0x04, 0xfb, 0x75, 0x49, 0x4f, 0xbb, 0x5b, 0x3a, 0xf9, 0xc6, 0xee, 0xff, 0x07, 0x93, 0x87, 0x39,
|
||||||
|
0xaf, 0xef, 0x1f, 0x6f, 0x3d, 0x60, 0xfd, 0xa0, 0x26, 0x6e, 0xc8, 0xa5, 0x47, 0xa6, 0x84, 0xde,
|
||||||
|
0xd6, 0x46, 0x24, 0xf2, 0x82, 0x1e, 0xfd, 0x99, 0xac, 0xb7, 0xef, 0x10, 0x1b, 0x35, 0x62, 0x36,
|
||||||
|
0x35, 0x62, 0x53, 0x42, 0x23, 0x80, 0x36, 0xac, 0xda, 0xa6, 0x75, 0xb2, 0xf5, 0x5f, 0xd8, 0x71,
|
||||||
|
0x23, 0x34, 0x62, 0xc3, 0x20, 0x6b, 0xc7, 0x6b, 0x63, 0x2b, 0xab, 0x39, 0xdf, 0xd5, 0x57, 0x00,
|
||||||
|
0x00, 0x00, 0xff, 0xff, 0xd4, 0x6a, 0xec, 0x7b, 0xfc, 0x01, 0x00, 0x00,
|
||||||
|
}
|
284
echoserver/echoserver.pb.gw.go
Normal file
284
echoserver/echoserver.pb.gw.go
Normal file
|
@ -0,0 +1,284 @@
|
||||||
|
// Code generated by protoc-gen-grpc-gateway
|
||||||
|
// source: echoserver.proto
|
||||||
|
// DO NOT EDIT!
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package echoserver is a reverse proxy.
|
||||||
|
|
||||||
|
It translates gRPC into RESTful JSON APIs.
|
||||||
|
*/
|
||||||
|
package echoserver
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
|
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/grpclog"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ codes.Code
|
||||||
|
var _ io.Reader
|
||||||
|
var _ status.Status
|
||||||
|
var _ = runtime.String
|
||||||
|
var _ = utilities.NewDoubleArray
|
||||||
|
|
||||||
|
func request_EchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (EchoService_EchoClient, runtime.ServerMetadata, error) {
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
stream, err := client.Echo(ctx)
|
||||||
|
if err != nil {
|
||||||
|
grpclog.Printf("Failed to start streaming: %v", err)
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
dec := marshaler.NewDecoder(req.Body)
|
||||||
|
handleSend := func() error {
|
||||||
|
var protoReq EchoRequest
|
||||||
|
err = dec.Decode(&protoReq)
|
||||||
|
if err == io.EOF {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
grpclog.Printf("Failed to decode request: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = stream.Send(&protoReq); err != nil {
|
||||||
|
grpclog.Printf("Failed to send request: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err := handleSend(); err != nil {
|
||||||
|
if cerr := stream.CloseSend(); cerr != nil {
|
||||||
|
grpclog.Printf("Failed to terminate client stream: %v", cerr)
|
||||||
|
}
|
||||||
|
if err == io.EOF {
|
||||||
|
return stream, metadata, nil
|
||||||
|
}
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
if err := handleSend(); err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := stream.CloseSend(); err != nil {
|
||||||
|
grpclog.Printf("Failed to terminate client stream: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
header, err := stream.Header()
|
||||||
|
if err != nil {
|
||||||
|
grpclog.Printf("Failed to get header from client: %v", err)
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
metadata.HeaderMD = header
|
||||||
|
return stream, metadata, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_EchoService_Stream_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (EchoService_StreamClient, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq Empty
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
stream, err := client.Stream(ctx, &protoReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
header, err := stream.Header()
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
metadata.HeaderMD = header
|
||||||
|
return stream, metadata, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_EchoService_Heartbeats_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (EchoService_HeartbeatsClient, runtime.ServerMetadata, error) {
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
stream, err := client.Heartbeats(ctx)
|
||||||
|
if err != nil {
|
||||||
|
grpclog.Printf("Failed to start streaming: %v", err)
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
dec := marshaler.NewDecoder(req.Body)
|
||||||
|
handleSend := func() error {
|
||||||
|
var protoReq Empty
|
||||||
|
err = dec.Decode(&protoReq)
|
||||||
|
if err == io.EOF {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
grpclog.Printf("Failed to decode request: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = stream.Send(&protoReq); err != nil {
|
||||||
|
grpclog.Printf("Failed to send request: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err := handleSend(); err != nil {
|
||||||
|
if cerr := stream.CloseSend(); cerr != nil {
|
||||||
|
grpclog.Printf("Failed to terminate client stream: %v", cerr)
|
||||||
|
}
|
||||||
|
if err == io.EOF {
|
||||||
|
return stream, metadata, nil
|
||||||
|
}
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
if err := handleSend(); err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := stream.CloseSend(); err != nil {
|
||||||
|
grpclog.Printf("Failed to terminate client stream: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
header, err := stream.Header()
|
||||||
|
if err != nil {
|
||||||
|
grpclog.Printf("Failed to get header from client: %v", err)
|
||||||
|
return nil, metadata, err
|
||||||
|
}
|
||||||
|
metadata.HeaderMD = header
|
||||||
|
return stream, metadata, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterEchoServiceHandlerFromEndpoint is same as RegisterEchoServiceHandler but
|
||||||
|
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||||
|
func RegisterEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||||
|
conn, err := grpc.Dial(endpoint, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
if cerr := conn.Close(); cerr != nil {
|
||||||
|
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
<-ctx.Done()
|
||||||
|
if cerr := conn.Close(); cerr != nil {
|
||||||
|
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}()
|
||||||
|
|
||||||
|
return RegisterEchoServiceHandler(ctx, mux, conn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterEchoServiceHandler registers the http handlers for service EchoService to "mux".
|
||||||
|
// The handlers forward requests to the grpc endpoint over "conn".
|
||||||
|
func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||||
|
client := NewEchoServiceClient(conn)
|
||||||
|
|
||||||
|
mux.Handle("POST", pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
defer cancel()
|
||||||
|
if cn, ok := w.(http.CloseNotifier); ok {
|
||||||
|
go func(done <-chan struct{}, closed <-chan bool) {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-closed:
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}(ctx.Done(), cn.CloseNotify())
|
||||||
|
}
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
}
|
||||||
|
resp, md, err := request_EchoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_EchoService_Echo_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_EchoService_Stream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
defer cancel()
|
||||||
|
if cn, ok := w.(http.CloseNotifier); ok {
|
||||||
|
go func(done <-chan struct{}, closed <-chan bool) {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-closed:
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}(ctx.Done(), cn.CloseNotify())
|
||||||
|
}
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
}
|
||||||
|
resp, md, err := request_EchoService_Stream_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_EchoService_Stream_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("POST", pattern_EchoService_Heartbeats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
defer cancel()
|
||||||
|
if cn, ok := w.(http.CloseNotifier); ok {
|
||||||
|
go func(done <-chan struct{}, closed <-chan bool) {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-closed:
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}(ctx.Done(), cn.CloseNotify())
|
||||||
|
}
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
}
|
||||||
|
resp, md, err := request_EchoService_Heartbeats_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||||
|
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_EchoService_Heartbeats_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
pattern_EchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"echo"}, ""))
|
||||||
|
|
||||||
|
pattern_EchoService_Stream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"echo"}, ""))
|
||||||
|
|
||||||
|
pattern_EchoService_Heartbeats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"heartbeats"}, ""))
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
forward_EchoService_Echo_0 = runtime.ForwardResponseStream
|
||||||
|
|
||||||
|
forward_EchoService_Stream_0 = runtime.ForwardResponseStream
|
||||||
|
|
||||||
|
forward_EchoService_Heartbeats_0 = runtime.ForwardResponseStream
|
||||||
|
)
|
34
echoserver/echoserver.proto
Normal file
34
echoserver/echoserver.proto
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
package echoserver;
|
||||||
|
|
||||||
|
import "google/api/annotations.proto";
|
||||||
|
|
||||||
|
message EchoRequest {
|
||||||
|
string message = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EchoResponse {
|
||||||
|
string message = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Heartbeat {
|
||||||
|
enum Status {
|
||||||
|
UNKNOWN = 0;
|
||||||
|
OK = 1;
|
||||||
|
}
|
||||||
|
Status status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Empty {}
|
||||||
|
|
||||||
|
service EchoService {
|
||||||
|
rpc Echo(stream EchoRequest) returns (stream EchoResponse) {
|
||||||
|
option (google.api.http) = {post: "/echo", body: "*"};
|
||||||
|
}
|
||||||
|
rpc Stream(Empty) returns (stream EchoResponse) {
|
||||||
|
option (google.api.http) = {get: "/echo"};
|
||||||
|
}
|
||||||
|
rpc Heartbeats(stream Empty) returns (stream Heartbeat) {
|
||||||
|
option (google.api.http) = {post: "/heartbeats"};
|
||||||
|
}
|
||||||
|
}
|
358
grpc/grpc.pb.go
358
grpc/grpc.pb.go
|
@ -10,10 +10,6 @@ It is generated from these files:
|
||||||
It has these top-level messages:
|
It has these top-level messages:
|
||||||
ServiceInput
|
ServiceInput
|
||||||
ServiceOutput
|
ServiceOutput
|
||||||
EchoRequest
|
|
||||||
EchoResponse
|
|
||||||
Heartbeat
|
|
||||||
Empty
|
|
||||||
*/
|
*/
|
||||||
package gwrpc
|
package gwrpc
|
||||||
|
|
||||||
|
@ -38,27 +34,6 @@ var _ = math.Inf
|
||||||
// proto package needs to be updated.
|
// proto package needs to be updated.
|
||||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type Heartbeat_Status int32
|
|
||||||
|
|
||||||
const (
|
|
||||||
Heartbeat_UNKNOWN Heartbeat_Status = 0
|
|
||||||
Heartbeat_OK Heartbeat_Status = 1
|
|
||||||
)
|
|
||||||
|
|
||||||
var Heartbeat_Status_name = map[int32]string{
|
|
||||||
0: "UNKNOWN",
|
|
||||||
1: "OK",
|
|
||||||
}
|
|
||||||
var Heartbeat_Status_value = map[string]int32{
|
|
||||||
"UNKNOWN": 0,
|
|
||||||
"OK": 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x Heartbeat_Status) String() string {
|
|
||||||
return proto.EnumName(Heartbeat_Status_name, int32(x))
|
|
||||||
}
|
|
||||||
func (Heartbeat_Status) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{4, 0} }
|
|
||||||
|
|
||||||
type ServiceInput struct {
|
type ServiceInput struct {
|
||||||
ServiceName string `protobuf:"bytes,1,opt,name=serviceName" json:"serviceName,omitempty"`
|
ServiceName string `protobuf:"bytes,1,opt,name=serviceName" json:"serviceName,omitempty"`
|
||||||
MethodName string `protobuf:"bytes,2,opt,name=methodName" json:"methodName,omitempty"`
|
MethodName string `protobuf:"bytes,2,opt,name=methodName" json:"methodName,omitempty"`
|
||||||
|
@ -107,70 +82,9 @@ func (m *ServiceOutput) GetResultStr() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type EchoRequest struct {
|
|
||||||
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *EchoRequest) Reset() { *m = EchoRequest{} }
|
|
||||||
func (m *EchoRequest) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*EchoRequest) ProtoMessage() {}
|
|
||||||
func (*EchoRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
|
||||||
|
|
||||||
func (m *EchoRequest) GetMessage() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.Message
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type EchoResponse struct {
|
|
||||||
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *EchoResponse) Reset() { *m = EchoResponse{} }
|
|
||||||
func (m *EchoResponse) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*EchoResponse) ProtoMessage() {}
|
|
||||||
func (*EchoResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
|
||||||
|
|
||||||
func (m *EchoResponse) GetMessage() string {
|
|
||||||
if m != nil {
|
|
||||||
return m.Message
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
type Heartbeat struct {
|
|
||||||
Status Heartbeat_Status `protobuf:"varint,1,opt,name=status,enum=gwrpc.Heartbeat_Status" json:"status,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Heartbeat) Reset() { *m = Heartbeat{} }
|
|
||||||
func (m *Heartbeat) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*Heartbeat) ProtoMessage() {}
|
|
||||||
func (*Heartbeat) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
|
||||||
|
|
||||||
func (m *Heartbeat) GetStatus() Heartbeat_Status {
|
|
||||||
if m != nil {
|
|
||||||
return m.Status
|
|
||||||
}
|
|
||||||
return Heartbeat_UNKNOWN
|
|
||||||
}
|
|
||||||
|
|
||||||
type Empty struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Empty) Reset() { *m = Empty{} }
|
|
||||||
func (m *Empty) String() string { return proto.CompactTextString(m) }
|
|
||||||
func (*Empty) ProtoMessage() {}
|
|
||||||
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*ServiceInput)(nil), "gwrpc.ServiceInput")
|
proto.RegisterType((*ServiceInput)(nil), "gwrpc.ServiceInput")
|
||||||
proto.RegisterType((*ServiceOutput)(nil), "gwrpc.ServiceOutput")
|
proto.RegisterType((*ServiceOutput)(nil), "gwrpc.ServiceOutput")
|
||||||
proto.RegisterType((*EchoRequest)(nil), "gwrpc.EchoRequest")
|
|
||||||
proto.RegisterType((*EchoResponse)(nil), "gwrpc.EchoResponse")
|
|
||||||
proto.RegisterType((*Heartbeat)(nil), "gwrpc.Heartbeat")
|
|
||||||
proto.RegisterType((*Empty)(nil), "gwrpc.Empty")
|
|
||||||
proto.RegisterEnum("gwrpc.Heartbeat_Status", Heartbeat_Status_name, Heartbeat_Status_value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference imports to suppress errors if they are not otherwise used.
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
@ -245,259 +159,27 @@ var _OverflowGateway_serviceDesc = grpc.ServiceDesc{
|
||||||
Metadata: "grpc/grpc.proto",
|
Metadata: "grpc/grpc.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client API for EchoService service
|
|
||||||
|
|
||||||
type EchoServiceClient interface {
|
|
||||||
Echo(ctx context.Context, opts ...grpc.CallOption) (EchoService_EchoClient, error)
|
|
||||||
Stream(ctx context.Context, in *Empty, opts ...grpc.CallOption) (EchoService_StreamClient, error)
|
|
||||||
Heartbeats(ctx context.Context, opts ...grpc.CallOption) (EchoService_HeartbeatsClient, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type echoServiceClient struct {
|
|
||||||
cc *grpc.ClientConn
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewEchoServiceClient(cc *grpc.ClientConn) EchoServiceClient {
|
|
||||||
return &echoServiceClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *echoServiceClient) Echo(ctx context.Context, opts ...grpc.CallOption) (EchoService_EchoClient, error) {
|
|
||||||
stream, err := grpc.NewClientStream(ctx, &_EchoService_serviceDesc.Streams[0], c.cc, "/gwrpc.EchoService/Echo", opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
x := &echoServiceEchoClient{stream}
|
|
||||||
return x, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type EchoService_EchoClient interface {
|
|
||||||
Send(*EchoRequest) error
|
|
||||||
Recv() (*EchoResponse, error)
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type echoServiceEchoClient struct {
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceEchoClient) Send(m *EchoRequest) error {
|
|
||||||
return x.ClientStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceEchoClient) Recv() (*EchoResponse, error) {
|
|
||||||
m := new(EchoResponse)
|
|
||||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *echoServiceClient) Stream(ctx context.Context, in *Empty, opts ...grpc.CallOption) (EchoService_StreamClient, error) {
|
|
||||||
stream, err := grpc.NewClientStream(ctx, &_EchoService_serviceDesc.Streams[1], c.cc, "/gwrpc.EchoService/Stream", opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
x := &echoServiceStreamClient{stream}
|
|
||||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := x.ClientStream.CloseSend(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return x, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type EchoService_StreamClient interface {
|
|
||||||
Recv() (*EchoResponse, error)
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type echoServiceStreamClient struct {
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceStreamClient) Recv() (*EchoResponse, error) {
|
|
||||||
m := new(EchoResponse)
|
|
||||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *echoServiceClient) Heartbeats(ctx context.Context, opts ...grpc.CallOption) (EchoService_HeartbeatsClient, error) {
|
|
||||||
stream, err := grpc.NewClientStream(ctx, &_EchoService_serviceDesc.Streams[2], c.cc, "/gwrpc.EchoService/Heartbeats", opts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
x := &echoServiceHeartbeatsClient{stream}
|
|
||||||
return x, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type EchoService_HeartbeatsClient interface {
|
|
||||||
Send(*Empty) error
|
|
||||||
Recv() (*Heartbeat, error)
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type echoServiceHeartbeatsClient struct {
|
|
||||||
grpc.ClientStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceHeartbeatsClient) Send(m *Empty) error {
|
|
||||||
return x.ClientStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceHeartbeatsClient) Recv() (*Heartbeat, error) {
|
|
||||||
m := new(Heartbeat)
|
|
||||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Server API for EchoService service
|
|
||||||
|
|
||||||
type EchoServiceServer interface {
|
|
||||||
Echo(EchoService_EchoServer) error
|
|
||||||
Stream(*Empty, EchoService_StreamServer) error
|
|
||||||
Heartbeats(EchoService_HeartbeatsServer) error
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterEchoServiceServer(s *grpc.Server, srv EchoServiceServer) {
|
|
||||||
s.RegisterService(&_EchoService_serviceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _EchoService_Echo_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
||||||
return srv.(EchoServiceServer).Echo(&echoServiceEchoServer{stream})
|
|
||||||
}
|
|
||||||
|
|
||||||
type EchoService_EchoServer interface {
|
|
||||||
Send(*EchoResponse) error
|
|
||||||
Recv() (*EchoRequest, error)
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type echoServiceEchoServer struct {
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceEchoServer) Send(m *EchoResponse) error {
|
|
||||||
return x.ServerStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceEchoServer) Recv() (*EchoRequest, error) {
|
|
||||||
m := new(EchoRequest)
|
|
||||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func _EchoService_Stream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
||||||
m := new(Empty)
|
|
||||||
if err := stream.RecvMsg(m); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return srv.(EchoServiceServer).Stream(m, &echoServiceStreamServer{stream})
|
|
||||||
}
|
|
||||||
|
|
||||||
type EchoService_StreamServer interface {
|
|
||||||
Send(*EchoResponse) error
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type echoServiceStreamServer struct {
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceStreamServer) Send(m *EchoResponse) error {
|
|
||||||
return x.ServerStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _EchoService_Heartbeats_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
||||||
return srv.(EchoServiceServer).Heartbeats(&echoServiceHeartbeatsServer{stream})
|
|
||||||
}
|
|
||||||
|
|
||||||
type EchoService_HeartbeatsServer interface {
|
|
||||||
Send(*Heartbeat) error
|
|
||||||
Recv() (*Empty, error)
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
type echoServiceHeartbeatsServer struct {
|
|
||||||
grpc.ServerStream
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceHeartbeatsServer) Send(m *Heartbeat) error {
|
|
||||||
return x.ServerStream.SendMsg(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *echoServiceHeartbeatsServer) Recv() (*Empty, error) {
|
|
||||||
m := new(Empty)
|
|
||||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var _EchoService_serviceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "gwrpc.EchoService",
|
|
||||||
HandlerType: (*EchoServiceServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{},
|
|
||||||
Streams: []grpc.StreamDesc{
|
|
||||||
{
|
|
||||||
StreamName: "Echo",
|
|
||||||
Handler: _EchoService_Echo_Handler,
|
|
||||||
ServerStreams: true,
|
|
||||||
ClientStreams: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
StreamName: "Stream",
|
|
||||||
Handler: _EchoService_Stream_Handler,
|
|
||||||
ServerStreams: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
StreamName: "Heartbeats",
|
|
||||||
Handler: _EchoService_Heartbeats_Handler,
|
|
||||||
ServerStreams: true,
|
|
||||||
ClientStreams: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Metadata: "grpc/grpc.proto",
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { proto.RegisterFile("grpc/grpc.proto", fileDescriptor0) }
|
func init() { proto.RegisterFile("grpc/grpc.proto", fileDescriptor0) }
|
||||||
|
|
||||||
var fileDescriptor0 = []byte{
|
var fileDescriptor0 = []byte{
|
||||||
// 473 bytes of a gzipped FileDescriptorProto
|
// 289 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x6e, 0xd3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x41, 0x4a, 0xc3, 0x40,
|
||||||
0x10, 0x86, 0xd9, 0x84, 0x24, 0xca, 0x38, 0xa1, 0xd6, 0xa4, 0x88, 0xc8, 0x2a, 0x55, 0xb4, 0x17,
|
0x14, 0x86, 0x49, 0x42, 0x84, 0xbe, 0x56, 0x2a, 0x63, 0x85, 0x12, 0x4a, 0x09, 0x59, 0x15, 0xc1,
|
||||||
0xa2, 0x4a, 0xd8, 0x25, 0x70, 0xa8, 0x22, 0xae, 0x16, 0xa0, 0x4a, 0x09, 0x4a, 0x84, 0x38, 0xf4,
|
0x0c, 0x56, 0x17, 0xa5, 0xfb, 0x22, 0x6e, 0xac, 0xb4, 0x4b, 0x57, 0x63, 0x1c, 0x63, 0x30, 0x99,
|
||||||
0xb4, 0x35, 0x8b, 0x13, 0x11, 0x7b, 0xcd, 0xee, 0x3a, 0x21, 0x57, 0x5e, 0x81, 0x17, 0xe2, 0x1d,
|
0x19, 0x26, 0x2f, 0x89, 0xd9, 0x7a, 0x05, 0x2f, 0xe4, 0x1d, 0xbc, 0x82, 0x07, 0x91, 0x24, 0x23,
|
||||||
0x38, 0x71, 0xe7, 0x41, 0x90, 0x77, 0x37, 0x69, 0x5a, 0x55, 0xbd, 0x58, 0x9e, 0xdf, 0xdf, 0xfc,
|
0x8d, 0xe0, 0x26, 0xe4, 0x7d, 0x7c, 0xfc, 0xff, 0x9b, 0x07, 0xe3, 0x58, 0xab, 0x88, 0x36, 0x9f,
|
||||||
0xb3, 0xf3, 0x7b, 0xe1, 0x28, 0x95, 0x45, 0x12, 0x55, 0x8f, 0xb0, 0x90, 0x42, 0x0b, 0x6c, 0xa4,
|
0x50, 0x69, 0x89, 0x92, 0xb8, 0x71, 0xa5, 0x55, 0xe4, 0xcd, 0x62, 0x29, 0xe3, 0x94, 0x53, 0xa6,
|
||||||
0x1b, 0x59, 0x24, 0xc1, 0x49, 0x2a, 0x44, 0xba, 0xe2, 0x11, 0x2b, 0x96, 0x11, 0xcb, 0x73, 0xa1,
|
0x12, 0xca, 0x84, 0x90, 0xc8, 0x30, 0x91, 0x22, 0xef, 0xa4, 0xe0, 0xd3, 0x82, 0xd1, 0x9e, 0xeb,
|
||||||
0x99, 0x5e, 0x8a, 0x5c, 0x59, 0x88, 0xfe, 0x26, 0xd0, 0x99, 0x73, 0xb9, 0x5e, 0x26, 0xfc, 0x43,
|
0x32, 0x89, 0xf8, 0xad, 0x50, 0x05, 0x12, 0x1f, 0x86, 0x79, 0x37, 0xdf, 0xb1, 0x8c, 0x4f, 0x2d,
|
||||||
0x5e, 0x94, 0x1a, 0x07, 0xe0, 0x29, 0x5b, 0x4f, 0x58, 0xc6, 0xfb, 0x64, 0x40, 0x86, 0xed, 0xd9,
|
0xdf, 0x5a, 0x0c, 0x76, 0x7d, 0x44, 0xe6, 0x00, 0x19, 0xc7, 0x17, 0xf9, 0xd4, 0x0a, 0x76, 0x2b,
|
||||||
0xa1, 0x84, 0xa7, 0x00, 0x19, 0xd7, 0x0b, 0xf1, 0xc5, 0x00, 0x35, 0x03, 0x1c, 0x28, 0xf8, 0x06,
|
0xf4, 0x08, 0xb9, 0x06, 0x57, 0x31, 0xcd, 0xb2, 0xa9, 0xe3, 0x3b, 0x8b, 0xe1, 0x72, 0x1e, 0xb6,
|
||||||
0x1a, 0x05, 0x93, 0x2c, 0xeb, 0xd7, 0x07, 0xf5, 0xa1, 0x37, 0x3a, 0x0d, 0xcd, 0x39, 0xc2, 0xc3,
|
0x7b, 0x84, 0xfd, 0x96, 0xf0, 0xbe, 0x11, 0x36, 0x02, 0x75, 0xbd, 0xeb, 0x64, 0x6f, 0x05, 0x70,
|
||||||
0x29, 0xe1, 0xc7, 0x0a, 0x88, 0x73, 0x2d, 0xb7, 0x33, 0x0b, 0x07, 0x17, 0x00, 0x37, 0x22, 0xfa,
|
0x80, 0xe4, 0x04, 0x9c, 0x57, 0x5e, 0x9b, 0xf6, 0xe6, 0x97, 0x4c, 0xc0, 0x2d, 0x59, 0x5a, 0xfc,
|
||||||
0x50, 0xff, 0xc6, 0xb7, 0x6e, 0x7a, 0xf5, 0x8a, 0xc7, 0xd0, 0x58, 0xb3, 0x55, 0xb9, 0x1b, 0x68,
|
0x16, 0x76, 0xc3, 0xda, 0x5e, 0x59, 0xc1, 0x05, 0x1c, 0x9b, 0xec, 0x6d, 0x81, 0xcd, 0x13, 0x66,
|
||||||
0x8b, 0x71, 0xed, 0x82, 0xd0, 0x97, 0xd0, 0x75, 0xde, 0xd3, 0x52, 0x57, 0x2b, 0x9c, 0x40, 0x5b,
|
0x30, 0xd0, 0x3c, 0x2f, 0x52, 0xdc, 0xa3, 0x36, 0x11, 0x07, 0xb0, 0x14, 0x30, 0xde, 0x96, 0x5c,
|
||||||
0x72, 0x55, 0xae, 0xf4, 0x5c, 0x4b, 0x67, 0x71, 0x23, 0xd0, 0x17, 0xe0, 0xc5, 0xc9, 0x42, 0xcc,
|
0x3f, 0xa7, 0xb2, 0xba, 0x61, 0xc8, 0x2b, 0x56, 0x93, 0x07, 0x18, 0x6d, 0xde, 0x78, 0x64, 0x52,
|
||||||
0xf8, 0xf7, 0x92, 0x2b, 0x8d, 0x7d, 0x68, 0x65, 0x5c, 0x29, 0x96, 0xee, 0x76, 0xdd, 0x95, 0x74,
|
0x72, 0x72, 0xfa, 0xcf, 0xca, 0xde, 0xe4, 0x2f, 0xec, 0xba, 0x02, 0xff, 0xfd, 0xeb, 0xfb, 0xc3,
|
||||||
0x08, 0x1d, 0x0b, 0xaa, 0x42, 0xe4, 0x8a, 0x3f, 0x40, 0x5e, 0x41, 0xfb, 0x3d, 0x67, 0x52, 0x5f,
|
0xf6, 0x82, 0x33, 0x5a, 0x5e, 0x52, 0x69, 0x72, 0xa9, 0x39, 0x57, 0xbe, 0xb6, 0xce, 0x1f, 0x8f,
|
||||||
0x73, 0xa6, 0x31, 0x82, 0xa6, 0xd2, 0x4c, 0x97, 0xca, 0x50, 0x4f, 0x46, 0xcf, 0xdc, 0xfe, 0x7b,
|
0xda, 0x43, 0x5f, 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x33, 0xa2, 0x39, 0xa0, 0x01, 0x00,
|
||||||
0x22, 0x9c, 0x9b, 0xcf, 0x33, 0x87, 0xd1, 0xe7, 0xd0, 0xb4, 0x0a, 0x7a, 0xd0, 0xfa, 0x34, 0xb9,
|
0x00,
|
||||||
0x9c, 0x4c, 0x3f, 0x4f, 0xfc, 0x47, 0xd8, 0x84, 0xda, 0xf4, 0xd2, 0x27, 0xb4, 0x05, 0x8d, 0x38,
|
|
||||||
0x2b, 0xf4, 0x76, 0x94, 0xc3, 0xd1, 0x74, 0xcd, 0xe5, 0xd7, 0x95, 0xd8, 0xbc, 0x63, 0x9a, 0x6f,
|
|
||||||
0xd8, 0x16, 0xaf, 0xa0, 0x13, 0xff, 0xe0, 0x89, 0x5b, 0x5f, 0x61, 0xef, 0x9e, 0xac, 0x83, 0xe3,
|
|
||||||
0xdb, 0xa2, 0x0d, 0x89, 0x0e, 0x7e, 0xfe, 0xf9, 0xf7, 0xab, 0x16, 0xd0, 0xa7, 0xd1, 0xfa, 0x55,
|
|
||||||
0x24, 0x9c, 0x6f, 0xe4, 0xfe, 0xb3, 0x1a, 0x93, 0xb3, 0xd1, 0x5f, 0x62, 0x93, 0x72, 0x7d, 0x18,
|
|
||||||
0xc3, 0xe3, 0xaa, 0x44, 0x74, 0x7e, 0x07, 0x29, 0x06, 0xbd, 0x5b, 0x9a, 0x0d, 0x8c, 0xfa, 0x66,
|
|
||||||
0x04, 0xd0, 0x46, 0xc4, 0x93, 0x85, 0x18, 0x93, 0xb3, 0x21, 0x39, 0x27, 0xf8, 0xb6, 0x5a, 0x57,
|
|
||||||
0x72, 0x96, 0x61, 0x67, 0xd7, 0x54, 0xad, 0x77, 0xbf, 0x45, 0xd7, 0x58, 0xb4, 0xd0, 0x5a, 0x9c,
|
|
||||||
0x13, 0x8c, 0x01, 0xf6, 0x41, 0xaa, 0x3b, 0x0e, 0xfe, 0xdd, 0xa4, 0x69, 0xcf, 0xb4, 0x77, 0xa9,
|
|
||||||
0x17, 0x2d, 0xf6, 0x4d, 0xd5, 0x21, 0xae, 0x9b, 0xe6, 0xf6, 0xbf, 0xfe, 0x1f, 0x00, 0x00, 0xff,
|
|
||||||
0xff, 0xec, 0x37, 0x72, 0xa5, 0x35, 0x03, 0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,127 +42,6 @@ func request_OverflowGateway_ExecServices_0(ctx context.Context, marshaler runti
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func request_EchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (EchoService_EchoClient, runtime.ServerMetadata, error) {
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
stream, err := client.Echo(ctx)
|
|
||||||
if err != nil {
|
|
||||||
grpclog.Printf("Failed to start streaming: %v", err)
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
dec := marshaler.NewDecoder(req.Body)
|
|
||||||
handleSend := func() error {
|
|
||||||
var protoReq EchoRequest
|
|
||||||
err = dec.Decode(&protoReq)
|
|
||||||
if err == io.EOF {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
grpclog.Printf("Failed to decode request: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err = stream.Send(&protoReq); err != nil {
|
|
||||||
grpclog.Printf("Failed to send request: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err := handleSend(); err != nil {
|
|
||||||
if cerr := stream.CloseSend(); cerr != nil {
|
|
||||||
grpclog.Printf("Failed to terminate client stream: %v", cerr)
|
|
||||||
}
|
|
||||||
if err == io.EOF {
|
|
||||||
return stream, metadata, nil
|
|
||||||
}
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
if err := handleSend(); err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := stream.CloseSend(); err != nil {
|
|
||||||
grpclog.Printf("Failed to terminate client stream: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
header, err := stream.Header()
|
|
||||||
if err != nil {
|
|
||||||
grpclog.Printf("Failed to get header from client: %v", err)
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
metadata.HeaderMD = header
|
|
||||||
return stream, metadata, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_EchoService_Stream_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (EchoService_StreamClient, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq Empty
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
stream, err := client.Stream(ctx, &protoReq)
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
header, err := stream.Header()
|
|
||||||
if err != nil {
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
metadata.HeaderMD = header
|
|
||||||
return stream, metadata, nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func request_EchoService_Heartbeats_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (EchoService_HeartbeatsClient, runtime.ServerMetadata, error) {
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
stream, err := client.Heartbeats(ctx)
|
|
||||||
if err != nil {
|
|
||||||
grpclog.Printf("Failed to start streaming: %v", err)
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
dec := marshaler.NewDecoder(req.Body)
|
|
||||||
handleSend := func() error {
|
|
||||||
var protoReq Empty
|
|
||||||
err = dec.Decode(&protoReq)
|
|
||||||
if err == io.EOF {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
grpclog.Printf("Failed to decode request: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err = stream.Send(&protoReq); err != nil {
|
|
||||||
grpclog.Printf("Failed to send request: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err := handleSend(); err != nil {
|
|
||||||
if cerr := stream.CloseSend(); cerr != nil {
|
|
||||||
grpclog.Printf("Failed to terminate client stream: %v", cerr)
|
|
||||||
}
|
|
||||||
if err == io.EOF {
|
|
||||||
return stream, metadata, nil
|
|
||||||
}
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
if err := handleSend(); err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := stream.CloseSend(); err != nil {
|
|
||||||
grpclog.Printf("Failed to terminate client stream: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
header, err := stream.Header()
|
|
||||||
if err != nil {
|
|
||||||
grpclog.Printf("Failed to get header from client: %v", err)
|
|
||||||
return nil, metadata, err
|
|
||||||
}
|
|
||||||
metadata.HeaderMD = header
|
|
||||||
return stream, metadata, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterOverflowGatewayHandlerFromEndpoint is same as RegisterOverflowGatewayHandler but
|
// RegisterOverflowGatewayHandlerFromEndpoint is same as RegisterOverflowGatewayHandler but
|
||||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||||
func RegisterOverflowGatewayHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
func RegisterOverflowGatewayHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||||
|
@ -231,136 +110,3 @@ var (
|
||||||
var (
|
var (
|
||||||
forward_OverflowGateway_ExecServices_0 = runtime.ForwardResponseMessage
|
forward_OverflowGateway_ExecServices_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterEchoServiceHandlerFromEndpoint is same as RegisterEchoServiceHandler but
|
|
||||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
|
||||||
func RegisterEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
|
||||||
conn, err := grpc.Dial(endpoint, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
<-ctx.Done()
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}()
|
|
||||||
|
|
||||||
return RegisterEchoServiceHandler(ctx, mux, conn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterEchoServiceHandler registers the http handlers for service EchoService to "mux".
|
|
||||||
// The handlers forward requests to the grpc endpoint over "conn".
|
|
||||||
func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
|
||||||
client := NewEchoServiceClient(conn)
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
|
||||||
defer cancel()
|
|
||||||
if cn, ok := w.(http.CloseNotifier); ok {
|
|
||||||
go func(done <-chan struct{}, closed <-chan bool) {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
case <-closed:
|
|
||||||
cancel()
|
|
||||||
}
|
|
||||||
}(ctx.Done(), cn.CloseNotify())
|
|
||||||
}
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
}
|
|
||||||
resp, md, err := request_EchoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_EchoService_Echo_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("GET", pattern_EchoService_Stream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
|
||||||
defer cancel()
|
|
||||||
if cn, ok := w.(http.CloseNotifier); ok {
|
|
||||||
go func(done <-chan struct{}, closed <-chan bool) {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
case <-closed:
|
|
||||||
cancel()
|
|
||||||
}
|
|
||||||
}(ctx.Done(), cn.CloseNotify())
|
|
||||||
}
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
}
|
|
||||||
resp, md, err := request_EchoService_Stream_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_EchoService_Stream_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_EchoService_Heartbeats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
|
||||||
defer cancel()
|
|
||||||
if cn, ok := w.(http.CloseNotifier); ok {
|
|
||||||
go func(done <-chan struct{}, closed <-chan bool) {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
case <-closed:
|
|
||||||
cancel()
|
|
||||||
}
|
|
||||||
}(ctx.Done(), cn.CloseNotify())
|
|
||||||
}
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
}
|
|
||||||
resp, md, err := request_EchoService_Heartbeats_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_EchoService_Heartbeats_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
pattern_EchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"echo"}, ""))
|
|
||||||
|
|
||||||
pattern_EchoService_Stream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"echo"}, ""))
|
|
||||||
|
|
||||||
pattern_EchoService_Heartbeats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"heartbeats"}, ""))
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
forward_EchoService_Echo_0 = runtime.ForwardResponseStream
|
|
||||||
|
|
||||||
forward_EchoService_Stream_0 = runtime.ForwardResponseStream
|
|
||||||
|
|
||||||
forward_EchoService_Heartbeats_0 = runtime.ForwardResponseStream
|
|
||||||
)
|
|
||||||
|
|
|
@ -21,33 +21,3 @@ service OverflowGateway {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message EchoRequest {
|
|
||||||
string message = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message EchoResponse {
|
|
||||||
string message = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Heartbeat {
|
|
||||||
enum Status {
|
|
||||||
UNKNOWN = 0;
|
|
||||||
OK = 1;
|
|
||||||
}
|
|
||||||
Status status = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Empty {}
|
|
||||||
|
|
||||||
service EchoService {
|
|
||||||
rpc Echo(stream EchoRequest) returns (stream EchoResponse) {
|
|
||||||
option (google.api.http) = {post: "/echo", body: "*"};
|
|
||||||
}
|
|
||||||
rpc Stream(Empty) returns (stream EchoResponse) {
|
|
||||||
option (google.api.http) = {get: "/echo"};
|
|
||||||
}
|
|
||||||
rpc Heartbeats(stream Empty) returns (stream Heartbeat) {
|
|
||||||
option (google.api.http) = {post: "/heartbeats"};
|
|
||||||
}
|
|
||||||
}
|
|
1
grpc/test.proto.go
Normal file
1
grpc/test.proto.go
Normal file
|
@ -0,0 +1 @@
|
||||||
|
package gwrpc
|
Loading…
Reference in New Issue
Block a user