diff --git a/_examples/README.md b/_examples/README.md new file mode 100644 index 0000000..0a83615 --- /dev/null +++ b/_examples/README.md @@ -0,0 +1,18 @@ +## wsechoserver +This example implements a websocket server using the proxy. The proto definition contains three RPCs: +- `Echo` is a bidirectional stream that echoes back the client request. +- `Stream` is a server-side stream that sends a fixed number of messages to the client and closes the connection +- `Heartbeat` is a bidirectional stream that sends back messages to the client at intervals. + +## Usage +Ideally, you should be able to run `go run _examples/cmd/wsechoserver` and start the example server. +To build it locally, you'll need to install: +- [buf](https://buf.build/) +- [protoc-gen-go](google.golang.org/protobuf/cmd/protoc-gen-go) +- [protoc-gen-go-grpc](google.golang.org/grpc/cmd/protoc-gen-go-grpc) +- [protoc-gen-go-grpc-gateway](github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway) + +Generate the protobuf files by running: +`buf generate -v .` + +You should now be able to start the server with the same run command above. \ No newline at end of file diff --git a/_examples/cmd/wsechoserver/echoserver/Makefile b/_examples/cmd/wsechoserver/echoserver/Makefile deleted file mode 100644 index 8498799..0000000 --- a/_examples/cmd/wsechoserver/echoserver/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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 diff --git a/_examples/cmd/wsechoserver/echoserver/buf.gen.yaml b/_examples/cmd/wsechoserver/echoserver/buf.gen.yaml new file mode 100644 index 0000000..24199e6 --- /dev/null +++ b/_examples/cmd/wsechoserver/echoserver/buf.gen.yaml @@ -0,0 +1,29 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: github.com/tmc/grpc-websocket-proxy/examples/cmd/wsechoserver/echoserver + except: + - buf.build/googleapis/googleapis + - buf.build/grpc-ecosystem/grpc-gateway + - buf.build/percona/third_party + +plugins: + - name: go + path: protoc-gen-go + out: . + opt: + - paths=source_relative + + - name: go-grpc + path: protoc-gen-go-grpc + out: . + opt: + - paths=source_relative + + - name: grpc-gateway + path: protoc-gen-grpc-gateway + out: . + opt: + - paths=source_relative + - logtostderr=true diff --git a/_examples/cmd/wsechoserver/echoserver/buf.lock b/_examples/cmd/wsechoserver/echoserver/buf.lock new file mode 100644 index 0000000..74972a9 --- /dev/null +++ b/_examples/cmd/wsechoserver/echoserver/buf.lock @@ -0,0 +1,7 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: googleapis + repository: googleapis + commit: 2646de1347094058879360e68cb2ccc6 diff --git a/_examples/cmd/wsechoserver/echoserver/buf.yaml b/_examples/cmd/wsechoserver/echoserver/buf.yaml new file mode 100644 index 0000000..0c71a8b --- /dev/null +++ b/_examples/cmd/wsechoserver/echoserver/buf.yaml @@ -0,0 +1,10 @@ +version: v1 +deps: + - buf.build/googleapis/googleapis +lint: + use: + - DEFAULT +breaking: + use: + - FILE + diff --git a/_examples/cmd/wsechoserver/echoserver/echoserver.pb.go b/_examples/cmd/wsechoserver/echoserver/echoserver.pb.go index 144516d..0fb95b1 100644 --- a/_examples/cmd/wsechoserver/echoserver/echoserver.pb.go +++ b/_examples/cmd/wsechoserver/echoserver/echoserver.pb.go @@ -1,41 +1,25 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc (unknown) // 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" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// 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 +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type Heartbeat_Status int32 @@ -44,334 +28,381 @@ const ( 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 +// Enum value maps for Heartbeat_Status. +var ( + Heartbeat_Status_name = map[int32]string{ + 0: "UNKNOWN", + 1: "OK", } - 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 + Heartbeat_Status_value = map[string]int32{ + "UNKNOWN": 0, + "OK": 1, } - return "" -} +) -type Heartbeat struct { - Status Heartbeat_Status `protobuf:"varint,1,opt,name=status,enum=echoserver.Heartbeat_Status" json:"status,omitempty"` +func (x Heartbeat_Status) Enum() *Heartbeat_Status { + p := new(Heartbeat_Status) + *p = x + return p } -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 +func (x Heartbeat_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -type Empty struct { +func (Heartbeat_Status) Descriptor() protoreflect.EnumDescriptor { + return file_echoserver_proto_enumTypes[0].Descriptor() } -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) +func (Heartbeat_Status) Type() protoreflect.EnumType { + return &file_echoserver_proto_enumTypes[0] } -// 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) +func (x Heartbeat_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } -type echoServiceClient struct { - cc *grpc.ClientConn +// Deprecated: Use Heartbeat_Status.Descriptor instead. +func (Heartbeat_Status) EnumDescriptor() ([]byte, []int) { + return file_echoserver_proto_rawDescGZIP(), []int{2, 0} } -func NewEchoServiceClient(cc *grpc.ClientConn) EchoServiceClient { - return &echoServiceClient{cc} -} +type EchoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -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 + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` } -type EchoService_EchoClient interface { - Send(*EchoRequest) error - Recv() (*EchoResponse, error) - grpc.ClientStream +func (x *EchoRequest) Reset() { + *x = EchoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_echoserver_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -type echoServiceEchoClient struct { - grpc.ClientStream +func (x *EchoRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (x *echoServiceEchoClient) Send(m *EchoRequest) error { - return x.ClientStream.SendMsg(m) -} +func (*EchoRequest) ProtoMessage() {} -func (x *echoServiceEchoClient) Recv() (*EchoResponse, error) { - m := new(EchoResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +func (x *EchoRequest) ProtoReflect() protoreflect.Message { + mi := &file_echoserver_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return m, nil + return mi.MessageOf(x) } -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 +// Deprecated: Use EchoRequest.ProtoReflect.Descriptor instead. +func (*EchoRequest) Descriptor() ([]byte, []int) { + return file_echoserver_proto_rawDescGZIP(), []int{0} } -type EchoService_StreamClient interface { - Recv() (*EchoResponse, error) - grpc.ClientStream +func (x *EchoRequest) GetMessage() string { + if x != nil { + return x.Message + } + return "" } -type echoServiceStreamClient struct { - grpc.ClientStream -} +type EchoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (x *echoServiceStreamClient) Recv() (*EchoResponse, error) { - m := new(EchoResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` } -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 +func (x *EchoResponse) Reset() { + *x = EchoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_echoserver_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - x := &echoServiceHeartbeatsClient{stream} - return x, nil } -type EchoService_HeartbeatsClient interface { - Send(*Empty) error - Recv() (*Heartbeat, error) - grpc.ClientStream +func (x *EchoResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -type echoServiceHeartbeatsClient struct { - grpc.ClientStream -} +func (*EchoResponse) ProtoMessage() {} -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 +func (x *EchoResponse) ProtoReflect() protoreflect.Message { + mi := &file_echoserver_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return m, nil + return mi.MessageOf(x) } -// Server API for EchoService service - -type EchoServiceServer interface { - Echo(EchoService_EchoServer) error - Stream(*Empty, EchoService_StreamServer) error - Heartbeats(EchoService_HeartbeatsServer) error +// Deprecated: Use EchoResponse.ProtoReflect.Descriptor instead. +func (*EchoResponse) Descriptor() ([]byte, []int) { + return file_echoserver_proto_rawDescGZIP(), []int{1} } -func RegisterEchoServiceServer(s *grpc.Server, srv EchoServiceServer) { - s.RegisterService(&_EchoService_serviceDesc, srv) +func (x *EchoResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" } -func _EchoService_Echo_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(EchoServiceServer).Echo(&echoServiceEchoServer{stream}) -} +type Heartbeat struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -type EchoService_EchoServer interface { - Send(*EchoResponse) error - Recv() (*EchoRequest, error) - grpc.ServerStream + Status Heartbeat_Status `protobuf:"varint,1,opt,name=status,proto3,enum=echoserver.Heartbeat_Status" json:"status,omitempty"` } -type echoServiceEchoServer struct { - grpc.ServerStream +func (x *Heartbeat) Reset() { + *x = Heartbeat{} + if protoimpl.UnsafeEnabled { + mi := &file_echoserver_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (x *echoServiceEchoServer) Send(m *EchoResponse) error { - return x.ServerStream.SendMsg(m) +func (x *Heartbeat) String() string { + return protoimpl.X.MessageStringOf(x) } -func (x *echoServiceEchoServer) Recv() (*EchoRequest, error) { - m := new(EchoRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +func (*Heartbeat) ProtoMessage() {} -func _EchoService_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Empty) - if err := stream.RecvMsg(m); err != nil { - return err +func (x *Heartbeat) ProtoReflect() protoreflect.Message { + mi := &file_echoserver_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return srv.(EchoServiceServer).Stream(m, &echoServiceStreamServer{stream}) + return mi.MessageOf(x) } -type EchoService_StreamServer interface { - Send(*EchoResponse) error - grpc.ServerStream +// Deprecated: Use Heartbeat.ProtoReflect.Descriptor instead. +func (*Heartbeat) Descriptor() ([]byte, []int) { + return file_echoserver_proto_rawDescGZIP(), []int{2} } -type echoServiceStreamServer struct { - grpc.ServerStream +func (x *Heartbeat) GetStatus() Heartbeat_Status { + if x != nil { + return x.Status + } + return Heartbeat_UNKNOWN } -func (x *echoServiceStreamServer) Send(m *EchoResponse) error { - return x.ServerStream.SendMsg(m) +type Empty struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -func _EchoService_Heartbeats_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(EchoServiceServer).Heartbeats(&echoServiceHeartbeatsServer{stream}) +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_echoserver_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -type EchoService_HeartbeatsServer interface { - Send(*Heartbeat) error - Recv() (*Empty, error) - grpc.ServerStream +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) } -type echoServiceHeartbeatsServer struct { - grpc.ServerStream -} +func (*Empty) ProtoMessage() {} -func (x *echoServiceHeartbeatsServer) Send(m *Heartbeat) error { - return x.ServerStream.SendMsg(m) -} +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_echoserver_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_echoserver_proto_rawDescGZIP(), []int{3} +} + +var File_echoserver_proto protoreflect.FileDescriptor + +var file_echoserver_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x65, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0a, 0x65, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x1a, 0x1c, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x27, 0x0a, 0x0b, + 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, + 0x60, 0x0a, 0x09, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x34, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x65, + 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, + 0x65, 0x61, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x22, 0x1d, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4b, 0x10, + 0x01, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0xf7, 0x01, 0x0a, 0x0b, 0x45, + 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4f, 0x0a, 0x04, 0x45, 0x63, + 0x68, 0x6f, 0x12, 0x17, 0x2e, 0x65, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, + 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x65, 0x63, + 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x22, 0x05, 0x2f, + 0x65, 0x63, 0x68, 0x6f, 0x3a, 0x01, 0x2a, 0x28, 0x01, 0x30, 0x01, 0x12, 0x46, 0x0a, 0x06, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x11, 0x2e, 0x65, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x65, 0x63, 0x68, 0x6f, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x65, 0x63, 0x68, + 0x6f, 0x30, 0x01, 0x12, 0x4f, 0x0a, 0x0a, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, + 0x73, 0x12, 0x11, 0x2e, 0x65, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x15, 0x2e, 0x65, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x22, 0x13, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x0d, 0x22, 0x0b, 0x2f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x73, + 0x28, 0x01, 0x30, 0x01, 0x42, 0xb3, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x63, 0x68, + 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x42, 0x0f, 0x45, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6d, 0x63, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, + 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x77, 0x73, 0x65, + 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0xa2, 0x02, 0x03, 0x45, 0x58, 0x58, 0xaa, 0x02, 0x0a, 0x45, 0x63, 0x68, + 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0xca, 0x02, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0xe2, 0x02, 0x16, 0x45, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0a, + 0x45, 0x63, 0x68, 0x6f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_echoserver_proto_rawDescOnce sync.Once + file_echoserver_proto_rawDescData = file_echoserver_proto_rawDesc +) -func (x *echoServiceHeartbeatsServer) Recv() (*Empty, error) { - m := new(Empty) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err +func file_echoserver_proto_rawDescGZIP() []byte { + file_echoserver_proto_rawDescOnce.Do(func() { + file_echoserver_proto_rawDescData = protoimpl.X.CompressGZIP(file_echoserver_proto_rawDescData) + }) + return file_echoserver_proto_rawDescData +} + +var file_echoserver_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_echoserver_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_echoserver_proto_goTypes = []interface{}{ + (Heartbeat_Status)(0), // 0: echoserver.Heartbeat.Status + (*EchoRequest)(nil), // 1: echoserver.EchoRequest + (*EchoResponse)(nil), // 2: echoserver.EchoResponse + (*Heartbeat)(nil), // 3: echoserver.Heartbeat + (*Empty)(nil), // 4: echoserver.Empty +} +var file_echoserver_proto_depIdxs = []int32{ + 0, // 0: echoserver.Heartbeat.status:type_name -> echoserver.Heartbeat.Status + 1, // 1: echoserver.EchoService.Echo:input_type -> echoserver.EchoRequest + 4, // 2: echoserver.EchoService.Stream:input_type -> echoserver.Empty + 4, // 3: echoserver.EchoService.Heartbeats:input_type -> echoserver.Empty + 2, // 4: echoserver.EchoService.Echo:output_type -> echoserver.EchoResponse + 2, // 5: echoserver.EchoService.Stream:output_type -> echoserver.EchoResponse + 3, // 6: echoserver.EchoService.Heartbeats:output_type -> echoserver.Heartbeat + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_echoserver_proto_init() } +func file_echoserver_proto_init() { + if File_echoserver_proto != nil { + return } - 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, + if !protoimpl.UnsafeEnabled { + file_echoserver_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EchoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_echoserver_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EchoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_echoserver_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Heartbeat); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_echoserver_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_echoserver_proto_rawDesc, + NumEnums: 1, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, }, - }, - 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, + GoTypes: file_echoserver_proto_goTypes, + DependencyIndexes: file_echoserver_proto_depIdxs, + EnumInfos: file_echoserver_proto_enumTypes, + MessageInfos: file_echoserver_proto_msgTypes, + }.Build() + File_echoserver_proto = out.File + file_echoserver_proto_rawDesc = nil + file_echoserver_proto_goTypes = nil + file_echoserver_proto_depIdxs = nil } diff --git a/_examples/cmd/wsechoserver/echoserver/echoserver.pb.gw.go b/_examples/cmd/wsechoserver/echoserver/echoserver.pb.gw.go index f261ede..89c0a37 100644 --- a/_examples/cmd/wsechoserver/echoserver/echoserver.pb.gw.go +++ b/_examples/cmd/wsechoserver/echoserver/echoserver.pb.gw.go @@ -1,6 +1,5 @@ -// Code generated by protoc-gen-grpc-gateway +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: echoserver.proto -// DO NOT EDIT! /* Package echoserver is a reverse proxy. @@ -10,58 +9,52 @@ It translates gRPC into RESTful JSON APIs. package echoserver import ( + "context" "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" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" ) +// Suppress "imported and not used" errors var _ codes.Code var _ io.Reader var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray +var _ = metadata.Join 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) + grpclog.Infof("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) + err := dec.Decode(&protoReq) if err == io.EOF { return err } if err != nil { - grpclog.Printf("Failed to decode request: %v", err) + grpclog.Infof("Failed to decode request: %v", err) return err } - if err = stream.Send(&protoReq); err != nil { - grpclog.Printf("Failed to send request: %v", err) + if err := stream.Send(&protoReq); err != nil { + grpclog.Infof("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 { @@ -69,12 +62,12 @@ func request_EchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler } } if err := stream.CloseSend(); err != nil { - grpclog.Printf("Failed to terminate client stream: %v", err) + grpclog.Infof("Failed to terminate client stream: %v", err) } }() header, err := stream.Header() if err != nil { - grpclog.Printf("Failed to get header from client: %v", err) + grpclog.Infof("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header @@ -102,35 +95,26 @@ func request_EchoService_Heartbeats_0(ctx context.Context, marshaler runtime.Mar var metadata runtime.ServerMetadata stream, err := client.Heartbeats(ctx) if err != nil { - grpclog.Printf("Failed to start streaming: %v", err) + grpclog.Infof("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) + err := dec.Decode(&protoReq) if err == io.EOF { return err } if err != nil { - grpclog.Printf("Failed to decode request: %v", err) + grpclog.Infof("Failed to decode request: %v", err) return err } - if err = stream.Send(&protoReq); err != nil { - grpclog.Printf("Failed to send request: %v", err) + if err := stream.Send(&protoReq); err != nil { + grpclog.Infof("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 { @@ -138,18 +122,48 @@ func request_EchoService_Heartbeats_0(ctx context.Context, marshaler runtime.Mar } } if err := stream.CloseSend(); err != nil { - grpclog.Printf("Failed to terminate client stream: %v", err) + grpclog.Infof("Failed to terminate client stream: %v", err) } }() header, err := stream.Header() if err != nil { - grpclog.Printf("Failed to get header from client: %v", err) + grpclog.Infof("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } +// RegisterEchoServiceHandlerServer registers the http handlers for service EchoService to "mux". +// UnaryRPC :call EchoServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterEchoServiceHandlerFromEndpoint instead. +func RegisterEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EchoServiceServer) error { + + mux.Handle("POST", pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") + _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + }) + + mux.Handle("GET", pattern_EchoService_Stream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") + _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + }) + + mux.Handle("POST", pattern_EchoService_Heartbeats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") + _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + }) + + return 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) { @@ -160,14 +174,14 @@ func RegisterEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.Se defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Infof("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) + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -178,26 +192,27 @@ func RegisterEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.Se // 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) + return RegisterEchoServiceHandlerClient(ctx, mux, NewEchoServiceClient(conn)) +} + +// RegisterEchoServiceHandlerClient registers the http handlers for service EchoService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EchoServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EchoServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "EchoServiceClient" to call the correct interceptors. +func RegisterEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EchoServiceClient) error { mux.Handle("POST", pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithCancel(req.Context()) 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) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/echoserver.EchoService/Echo", runtime.WithHTTPPathPattern("/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return } - resp, md, err := request_EchoService_Echo_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EchoService_Echo_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -209,23 +224,16 @@ func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn }) mux.Handle("GET", pattern_EchoService_Stream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithCancel(req.Context()) 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) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/echoserver.EchoService/Stream", runtime.WithHTTPPathPattern("/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return } - resp, md, err := request_EchoService_Stream_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EchoService_Stream_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -237,23 +245,16 @@ func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn }) mux.Handle("POST", pattern_EchoService_Heartbeats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithCancel(req.Context()) 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) + var err error + ctx, err = runtime.AnnotateContext(ctx, mux, req, "/echoserver.EchoService/Heartbeats", runtime.WithHTTPPathPattern("/heartbeats")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return } - resp, md, err := request_EchoService_Heartbeats_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_EchoService_Heartbeats_0(ctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/_examples/cmd/wsechoserver/echoserver/echoserver_grpc.pb.go b/_examples/cmd/wsechoserver/echoserver/echoserver_grpc.pb.go new file mode 100644 index 0000000..85bf730 --- /dev/null +++ b/_examples/cmd/wsechoserver/echoserver/echoserver_grpc.pb.go @@ -0,0 +1,268 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: echoserver.proto + +package echoserver + +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 + +// EchoServiceClient is the client API for EchoService 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 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.ClientConnInterface +} + +func NewEchoServiceClient(cc grpc.ClientConnInterface) EchoServiceClient { + return &echoServiceClient{cc} +} + +func (c *echoServiceClient) Echo(ctx context.Context, opts ...grpc.CallOption) (EchoService_EchoClient, error) { + stream, err := c.cc.NewStream(ctx, &EchoService_ServiceDesc.Streams[0], "/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 := c.cc.NewStream(ctx, &EchoService_ServiceDesc.Streams[1], "/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 := c.cc.NewStream(ctx, &EchoService_ServiceDesc.Streams[2], "/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 +} + +// EchoServiceServer is the server API for EchoService service. +// All implementations must embed UnimplementedEchoServiceServer +// for forward compatibility +type EchoServiceServer interface { + Echo(EchoService_EchoServer) error + Stream(*Empty, EchoService_StreamServer) error + Heartbeats(EchoService_HeartbeatsServer) error + mustEmbedUnimplementedEchoServiceServer() +} + +// UnimplementedEchoServiceServer must be embedded to have forward compatible implementations. +type UnimplementedEchoServiceServer struct { +} + +func (UnimplementedEchoServiceServer) Echo(EchoService_EchoServer) error { + return status.Errorf(codes.Unimplemented, "method Echo not implemented") +} +func (UnimplementedEchoServiceServer) Stream(*Empty, EchoService_StreamServer) error { + return status.Errorf(codes.Unimplemented, "method Stream not implemented") +} +func (UnimplementedEchoServiceServer) Heartbeats(EchoService_HeartbeatsServer) error { + return status.Errorf(codes.Unimplemented, "method Heartbeats not implemented") +} +func (UnimplementedEchoServiceServer) mustEmbedUnimplementedEchoServiceServer() {} + +// UnsafeEchoServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to EchoServiceServer will +// result in compilation errors. +type UnsafeEchoServiceServer interface { + mustEmbedUnimplementedEchoServiceServer() +} + +func RegisterEchoServiceServer(s grpc.ServiceRegistrar, 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 +} + +// EchoService_ServiceDesc is the grpc.ServiceDesc for EchoService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +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", +} diff --git a/_examples/cmd/wsechoserver/echoserver/gen.go b/_examples/cmd/wsechoserver/echoserver/gen.go deleted file mode 100644 index 826287e..0000000 --- a/_examples/cmd/wsechoserver/echoserver/gen.go +++ /dev/null @@ -1,3 +0,0 @@ -//go:generate make - -package echoserver diff --git a/_examples/cmd/wsechoserver/main.go b/_examples/cmd/wsechoserver/main.go index 7248653..ce534f1 100644 --- a/_examples/cmd/wsechoserver/main.go +++ b/_examples/cmd/wsechoserver/main.go @@ -11,7 +11,7 @@ import ( _ "golang.org/x/net/trace" "github.com/golang/glog" - "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/tmc/grpc-websocket-proxy/examples/cmd/wsechoserver/echoserver" "github.com/tmc/grpc-websocket-proxy/wsproxy" "golang.org/x/net/context" diff --git a/_examples/cmd/wsechoserver/server.go b/_examples/cmd/wsechoserver/server.go index d86ea8a..0937c7c 100644 --- a/_examples/cmd/wsechoserver/server.go +++ b/_examples/cmd/wsechoserver/server.go @@ -10,7 +10,9 @@ import ( "github.com/tmc/grpc-websocket-proxy/examples/cmd/wsechoserver/echoserver" ) -type Server struct{} +type Server struct{ + echoserver.UnimplementedEchoServiceServer +} func (s *Server) Stream(_ *echoserver.Empty, stream echoserver.EchoService_StreamServer) error { start := time.Now() diff --git a/_examples/go.mod b/_examples/go.mod new file mode 100644 index 0000000..21354b5 --- /dev/null +++ b/_examples/go.mod @@ -0,0 +1,21 @@ +module github.com/tmc/grpc-websocket-proxy/examples + +go 1.18 + +require ( + github.com/golang/glog v1.0.0 + github.com/golang/protobuf v1.5.2 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3 + github.com/sirupsen/logrus v1.8.1 + github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 + golang.org/x/net v0.0.0-20220708220712-1185a9018129 + google.golang.org/genproto v0.0.0-20220708155623-50e5f4832e73 + google.golang.org/grpc v1.47.0 + google.golang.org/protobuf v1.28.0 +) + +require ( + github.com/gorilla/websocket v1.4.2 // indirect + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/_examples/go.sum b/_examples/go.sum new file mode 100644 index 0000000..f83f90b --- /dev/null +++ b/_examples/go.sum @@ -0,0 +1,157 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3 h1:BGNSrTRW4rwfhJiFwvwF4XQ0Y72Jj9YEgxVrtovbD5o= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3/go.mod h1:VHn7KgNsRriXa4mcgtkpR00OXyQY6g67JWMvn+R27A4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= +github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220708220712-1185a9018129 h1:vucSRfWwTsoXro7P+3Cjlr6flUMtzCwzlvkxEQtHHB0= +golang.org/x/net v0.0.0-20220708220712-1185a9018129/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20220708155623-50e5f4832e73 h1:sdZWfcGN37Dv0QWIhuasQGMzAQJOL2oqnvot4/kPgfQ= +google.golang.org/genproto v0.0.0-20220708155623-50e5f4832e73/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8= +google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/go.sum b/go.sum index f247863..e3ed4b5 100644 --- a/go.sum +++ b/go.sum @@ -19,7 +19,6 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=