Fix go mod issues

This commit is contained in:
Asim Aslam 2019-06-05 10:22:28 +01:00 committed by Vasiliy Tolstov
parent eaae419939
commit eff6cf4b56
4 changed files with 305 additions and 6 deletions

View File

@ -8,14 +8,14 @@ import (
"github.com/micro/go-micro/server" "github.com/micro/go-micro/server"
"google.golang.org/grpc" "google.golang.org/grpc"
pb "github.com/micro/examples/greeter/srv/proto/hello" pb "github.com/micro/go-micro/server/grpc/proto"
) )
// server is used to implement helloworld.GreeterServer. // server is used to implement helloworld.GreeterServer.
type sayServer struct{} type testServer struct{}
// SayHello implements helloworld.GreeterServer // TestHello implements helloworld.GreeterServer
func (s *sayServer) Hello(ctx context.Context, req *pb.Request, rsp *pb.Response) error { func (s *testServer) Call(ctx context.Context, req *pb.Request, rsp *pb.Response) error {
rsp.Msg = "Hello " + req.Name rsp.Msg = "Hello " + req.Name
return nil return nil
} }
@ -27,7 +27,7 @@ func TestGRPCServer(t *testing.T) {
server.Registry(r), server.Registry(r),
) )
pb.RegisterSayHandler(s, &sayServer{}) pb.RegisterTestHandler(s, &testServer{})
if err := s.Start(); err != nil { if err := s.Start(); err != nil {
t.Fatalf("failed to start: %v", err) t.Fatalf("failed to start: %v", err)
@ -50,7 +50,7 @@ func TestGRPCServer(t *testing.T) {
t.Fatalf("failed to dial server: %v", err) t.Fatalf("failed to dial server: %v", err)
} }
testMethods := []string{"/helloworld.Say/Hello", "/greeter.helloworld.Say/Hello"} testMethods := []string{"/test.Test/Call", "/go.micro.test.Test/Call"}
for _, method := range testMethods { for _, method := range testMethods {
rsp := pb.Response{} rsp := pb.Response{}

91
proto/test.micro.go Normal file
View File

@ -0,0 +1,91 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: go-micro/service/grpc/proto/test.proto
package test
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
client "github.com/micro/go-micro/client"
server "github.com/micro/go-micro/server"
)
// 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.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ client.Option
var _ server.Option
// Client API for Test service
type TestService interface {
Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
}
type testService struct {
c client.Client
name string
}
func NewTestService(name string, c client.Client) TestService {
if c == nil {
c = client.NewClient()
}
if len(name) == 0 {
name = "test"
}
return &testService{
c: c,
name: name,
}
}
func (c *testService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
req := c.c.NewRequest(c.name, "Test.Call", in)
out := new(Response)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Test service
type TestHandler interface {
Call(context.Context, *Request, *Response) error
}
func RegisterTestHandler(s server.Server, hdlr TestHandler, opts ...server.HandlerOption) error {
type test interface {
Call(ctx context.Context, in *Request, out *Response) error
}
type Test struct {
test
}
h := &testHandler{hdlr}
return s.Handle(s.NewHandler(&Test{h}, opts...))
}
type testHandler struct {
TestHandler
}
func (h *testHandler) Call(ctx context.Context, in *Request, out *Response) error {
return h.TestHandler.Call(ctx, in, out)
}

195
proto/test.pb.go Normal file
View File

@ -0,0 +1,195 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: go-micro/service/grpc/proto/test.proto
package test
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
math "math"
)
// 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.ProtoPackageIsVersion3 // please upgrade the proto package
type Request struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Request) Reset() { *m = Request{} }
func (m *Request) String() string { return proto.CompactTextString(m) }
func (*Request) ProtoMessage() {}
func (*Request) Descriptor() ([]byte, []int) {
return fileDescriptor_a22a4245ce525bcd, []int{0}
}
func (m *Request) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Request.Unmarshal(m, b)
}
func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Request.Marshal(b, m, deterministic)
}
func (m *Request) XXX_Merge(src proto.Message) {
xxx_messageInfo_Request.Merge(m, src)
}
func (m *Request) XXX_Size() int {
return xxx_messageInfo_Request.Size(m)
}
func (m *Request) XXX_DiscardUnknown() {
xxx_messageInfo_Request.DiscardUnknown(m)
}
var xxx_messageInfo_Request proto.InternalMessageInfo
func (m *Request) GetName() string {
if m != nil {
return m.Name
}
return ""
}
type Response struct {
Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Response) Reset() { *m = Response{} }
func (m *Response) String() string { return proto.CompactTextString(m) }
func (*Response) ProtoMessage() {}
func (*Response) Descriptor() ([]byte, []int) {
return fileDescriptor_a22a4245ce525bcd, []int{1}
}
func (m *Response) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Response.Unmarshal(m, b)
}
func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Response.Marshal(b, m, deterministic)
}
func (m *Response) XXX_Merge(src proto.Message) {
xxx_messageInfo_Response.Merge(m, src)
}
func (m *Response) XXX_Size() int {
return xxx_messageInfo_Response.Size(m)
}
func (m *Response) XXX_DiscardUnknown() {
xxx_messageInfo_Response.DiscardUnknown(m)
}
var xxx_messageInfo_Response proto.InternalMessageInfo
func (m *Response) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func init() {
proto.RegisterType((*Request)(nil), "Request")
proto.RegisterType((*Response)(nil), "Response")
}
func init() {
proto.RegisterFile("go-micro/service/grpc/proto/test.proto", fileDescriptor_a22a4245ce525bcd)
}
var fileDescriptor_a22a4245ce525bcd = []byte{
// 142 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xcf, 0xd7, 0xcd,
0xcd, 0x4c, 0x2e, 0xca, 0xd7, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x4f, 0x2f, 0x2a,
0x48, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x49, 0x2d, 0x2e, 0xd1, 0x03, 0x33, 0x95,
0x64, 0xb9, 0xd8, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x84, 0x84, 0xb8, 0x58, 0xf2, 0x12,
0x73, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, 0x6c, 0x25, 0x19, 0x2e, 0x8e, 0xa0,
0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x21, 0x01, 0x2e, 0xe6, 0xdc, 0xe2, 0x74, 0xa8, 0x34,
0x88, 0x69, 0xa4, 0xca, 0xc5, 0x12, 0x02, 0xd2, 0x29, 0xcb, 0xc5, 0xe2, 0x9c, 0x98, 0x93, 0x23,
0xc4, 0xa1, 0x07, 0x35, 0x4b, 0x8a, 0x53, 0x0f, 0xa6, 0x4d, 0x89, 0x21, 0x89, 0x0d, 0x6c, 0x95,
0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x96, 0x1b, 0x22, 0x44, 0x94, 0x00, 0x00, 0x00,
}
// 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
// TestClient is the client API for Test service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type TestClient interface {
Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
}
type testClient struct {
cc *grpc.ClientConn
}
func NewTestClient(cc *grpc.ClientConn) TestClient {
return &testClient{cc}
}
func (c *testClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/Test/Call", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TestServer is the server API for Test service.
type TestServer interface {
Call(context.Context, *Request) (*Response, error)
}
func RegisterTestServer(s *grpc.Server, srv TestServer) {
s.RegisterService(&_Test_serviceDesc, srv)
}
func _Test_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Request)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TestServer).Call(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Test/Call",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestServer).Call(ctx, req.(*Request))
}
return interceptor(ctx, in, info, handler)
}
var _Test_serviceDesc = grpc.ServiceDesc{
ServiceName: "Test",
HandlerType: (*TestServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Call",
Handler: _Test_Call_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "go-micro/service/grpc/proto/test.proto",
}

13
proto/test.proto Normal file
View File

@ -0,0 +1,13 @@
syntax = "proto3";
service Test {
rpc Call(Request) returns (Response) {}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}