foo test service

This commit is contained in:
2020-06-30 17:18:54 +08:00
parent 769d7ce330
commit 4a81768f2b
13 changed files with 872 additions and 4 deletions

View File

@ -0,0 +1,262 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/foo/foo.proto
package go_micro_srv_foo
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 Foo service
type FooService interface {
Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
Stream(ctx context.Context, in *StreamingRequest, opts ...client.CallOption) (Foo_StreamService, error)
PingPong(ctx context.Context, opts ...client.CallOption) (Foo_PingPongService, error)
}
type fooService struct {
c client.Client
name string
}
func NewFooService(name string, c client.Client) FooService {
if c == nil {
c = client.NewClient()
}
if len(name) == 0 {
name = "go.micro.srv.foo"
}
return &fooService{
c: c,
name: name,
}
}
func (c *fooService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
req := c.c.NewRequest(c.name, "Foo.Call", in)
out := new(Response)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *fooService) Stream(ctx context.Context, in *StreamingRequest, opts ...client.CallOption) (Foo_StreamService, error) {
req := c.c.NewRequest(c.name, "Foo.Stream", &StreamingRequest{})
stream, err := c.c.Stream(ctx, req, opts...)
if err != nil {
return nil, err
}
if err := stream.Send(in); err != nil {
return nil, err
}
return &fooServiceStream{stream}, nil
}
type Foo_StreamService interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*StreamingResponse, error)
}
type fooServiceStream struct {
stream client.Stream
}
func (x *fooServiceStream) Close() error {
return x.stream.Close()
}
func (x *fooServiceStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *fooServiceStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *fooServiceStream) Recv() (*StreamingResponse, error) {
m := new(StreamingResponse)
err := x.stream.Recv(m)
if err != nil {
return nil, err
}
return m, nil
}
func (c *fooService) PingPong(ctx context.Context, opts ...client.CallOption) (Foo_PingPongService, error) {
req := c.c.NewRequest(c.name, "Foo.PingPong", &Ping{})
stream, err := c.c.Stream(ctx, req, opts...)
if err != nil {
return nil, err
}
return &fooServicePingPong{stream}, nil
}
type Foo_PingPongService interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*Ping) error
Recv() (*Pong, error)
}
type fooServicePingPong struct {
stream client.Stream
}
func (x *fooServicePingPong) Close() error {
return x.stream.Close()
}
func (x *fooServicePingPong) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *fooServicePingPong) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *fooServicePingPong) Send(m *Ping) error {
return x.stream.Send(m)
}
func (x *fooServicePingPong) Recv() (*Pong, error) {
m := new(Pong)
err := x.stream.Recv(m)
if err != nil {
return nil, err
}
return m, nil
}
// Server API for Foo service
type FooHandler interface {
Call(context.Context, *Request, *Response) error
Stream(context.Context, *StreamingRequest, Foo_StreamStream) error
PingPong(context.Context, Foo_PingPongStream) error
}
func RegisterFooHandler(s server.Server, hdlr FooHandler, opts ...server.HandlerOption) error {
type foo interface {
Call(ctx context.Context, in *Request, out *Response) error
Stream(ctx context.Context, stream server.Stream) error
PingPong(ctx context.Context, stream server.Stream) error
}
type Foo struct {
foo
}
h := &fooHandler{hdlr}
return s.Handle(s.NewHandler(&Foo{h}, opts...))
}
type fooHandler struct {
FooHandler
}
func (h *fooHandler) Call(ctx context.Context, in *Request, out *Response) error {
return h.FooHandler.Call(ctx, in, out)
}
func (h *fooHandler) Stream(ctx context.Context, stream server.Stream) error {
m := new(StreamingRequest)
if err := stream.Recv(m); err != nil {
return err
}
return h.FooHandler.Stream(ctx, m, &fooStreamStream{stream})
}
type Foo_StreamStream interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*StreamingResponse) error
}
type fooStreamStream struct {
stream server.Stream
}
func (x *fooStreamStream) Close() error {
return x.stream.Close()
}
func (x *fooStreamStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *fooStreamStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *fooStreamStream) Send(m *StreamingResponse) error {
return x.stream.Send(m)
}
func (h *fooHandler) PingPong(ctx context.Context, stream server.Stream) error {
return h.FooHandler.PingPong(ctx, &fooPingPongStream{stream})
}
type Foo_PingPongStream interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*Pong) error
Recv() (*Ping, error)
}
type fooPingPongStream struct {
stream server.Stream
}
func (x *fooPingPongStream) Close() error {
return x.stream.Close()
}
func (x *fooPingPongStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *fooPingPongStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *fooPingPongStream) Send(m *Pong) error {
return x.stream.Send(m)
}
func (x *fooPingPongStream) Recv() (*Ping, error) {
m := new(Ping)
if err := x.stream.Recv(m); err != nil {
return nil, err
}
return m, nil
}

View File

@ -0,0 +1,327 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: proto/foo/foo.proto
package go_micro_srv_foo
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
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 Message struct {
Say string `protobuf:"bytes,1,opt,name=say,proto3" json:"say,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {}
func (*Message) Descriptor() ([]byte, []int) {
return fileDescriptor_033365c2599c4e50, []int{0}
}
func (m *Message) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Message.Unmarshal(m, b)
}
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
}
func (m *Message) XXX_Merge(src proto.Message) {
xxx_messageInfo_Message.Merge(m, src)
}
func (m *Message) XXX_Size() int {
return xxx_messageInfo_Message.Size(m)
}
func (m *Message) XXX_DiscardUnknown() {
xxx_messageInfo_Message.DiscardUnknown(m)
}
var xxx_messageInfo_Message proto.InternalMessageInfo
func (m *Message) GetSay() string {
if m != nil {
return m.Say
}
return ""
}
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_033365c2599c4e50, []int{1}
}
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_033365c2599c4e50, []int{2}
}
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 ""
}
type StreamingRequest struct {
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StreamingRequest) Reset() { *m = StreamingRequest{} }
func (m *StreamingRequest) String() string { return proto.CompactTextString(m) }
func (*StreamingRequest) ProtoMessage() {}
func (*StreamingRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_033365c2599c4e50, []int{3}
}
func (m *StreamingRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StreamingRequest.Unmarshal(m, b)
}
func (m *StreamingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StreamingRequest.Marshal(b, m, deterministic)
}
func (m *StreamingRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_StreamingRequest.Merge(m, src)
}
func (m *StreamingRequest) XXX_Size() int {
return xxx_messageInfo_StreamingRequest.Size(m)
}
func (m *StreamingRequest) XXX_DiscardUnknown() {
xxx_messageInfo_StreamingRequest.DiscardUnknown(m)
}
var xxx_messageInfo_StreamingRequest proto.InternalMessageInfo
func (m *StreamingRequest) GetCount() int64 {
if m != nil {
return m.Count
}
return 0
}
type StreamingResponse struct {
Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StreamingResponse) Reset() { *m = StreamingResponse{} }
func (m *StreamingResponse) String() string { return proto.CompactTextString(m) }
func (*StreamingResponse) ProtoMessage() {}
func (*StreamingResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_033365c2599c4e50, []int{4}
}
func (m *StreamingResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StreamingResponse.Unmarshal(m, b)
}
func (m *StreamingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StreamingResponse.Marshal(b, m, deterministic)
}
func (m *StreamingResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_StreamingResponse.Merge(m, src)
}
func (m *StreamingResponse) XXX_Size() int {
return xxx_messageInfo_StreamingResponse.Size(m)
}
func (m *StreamingResponse) XXX_DiscardUnknown() {
xxx_messageInfo_StreamingResponse.DiscardUnknown(m)
}
var xxx_messageInfo_StreamingResponse proto.InternalMessageInfo
func (m *StreamingResponse) GetCount() int64 {
if m != nil {
return m.Count
}
return 0
}
type Ping struct {
Stroke int64 `protobuf:"varint,1,opt,name=stroke,proto3" json:"stroke,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Ping) Reset() { *m = Ping{} }
func (m *Ping) String() string { return proto.CompactTextString(m) }
func (*Ping) ProtoMessage() {}
func (*Ping) Descriptor() ([]byte, []int) {
return fileDescriptor_033365c2599c4e50, []int{5}
}
func (m *Ping) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Ping.Unmarshal(m, b)
}
func (m *Ping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Ping.Marshal(b, m, deterministic)
}
func (m *Ping) XXX_Merge(src proto.Message) {
xxx_messageInfo_Ping.Merge(m, src)
}
func (m *Ping) XXX_Size() int {
return xxx_messageInfo_Ping.Size(m)
}
func (m *Ping) XXX_DiscardUnknown() {
xxx_messageInfo_Ping.DiscardUnknown(m)
}
var xxx_messageInfo_Ping proto.InternalMessageInfo
func (m *Ping) GetStroke() int64 {
if m != nil {
return m.Stroke
}
return 0
}
type Pong struct {
Stroke int64 `protobuf:"varint,1,opt,name=stroke,proto3" json:"stroke,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Pong) Reset() { *m = Pong{} }
func (m *Pong) String() string { return proto.CompactTextString(m) }
func (*Pong) ProtoMessage() {}
func (*Pong) Descriptor() ([]byte, []int) {
return fileDescriptor_033365c2599c4e50, []int{6}
}
func (m *Pong) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Pong.Unmarshal(m, b)
}
func (m *Pong) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Pong.Marshal(b, m, deterministic)
}
func (m *Pong) XXX_Merge(src proto.Message) {
xxx_messageInfo_Pong.Merge(m, src)
}
func (m *Pong) XXX_Size() int {
return xxx_messageInfo_Pong.Size(m)
}
func (m *Pong) XXX_DiscardUnknown() {
xxx_messageInfo_Pong.DiscardUnknown(m)
}
var xxx_messageInfo_Pong proto.InternalMessageInfo
func (m *Pong) GetStroke() int64 {
if m != nil {
return m.Stroke
}
return 0
}
func init() {
proto.RegisterType((*Message)(nil), "go.micro.srv.foo.Message")
proto.RegisterType((*Request)(nil), "go.micro.srv.foo.Request")
proto.RegisterType((*Response)(nil), "go.micro.srv.foo.Response")
proto.RegisterType((*StreamingRequest)(nil), "go.micro.srv.foo.StreamingRequest")
proto.RegisterType((*StreamingResponse)(nil), "go.micro.srv.foo.StreamingResponse")
proto.RegisterType((*Ping)(nil), "go.micro.srv.foo.Ping")
proto.RegisterType((*Pong)(nil), "go.micro.srv.foo.Pong")
}
func init() { proto.RegisterFile("proto/foo/foo.proto", fileDescriptor_033365c2599c4e50) }
var fileDescriptor_033365c2599c4e50 = []byte{
// 268 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xcf, 0x4a, 0xc4, 0x30,
0x10, 0xc6, 0x37, 0x6c, 0xed, 0xae, 0x73, 0xaa, 0xa3, 0x88, 0xd6, 0x3f, 0x48, 0xbc, 0xd4, 0x4b,
0x5c, 0xf4, 0x01, 0x14, 0x04, 0x6f, 0x82, 0x54, 0x7c, 0x80, 0xba, 0x64, 0x43, 0x71, 0x9b, 0x59,
0x33, 0x59, 0xc1, 0xa7, 0xf5, 0x55, 0xa4, 0x69, 0x0a, 0xb2, 0x5b, 0x3d, 0x04, 0x66, 0xf2, 0xfb,
0x66, 0xf8, 0xbe, 0x04, 0xf6, 0x57, 0x8e, 0x3c, 0x5d, 0x2f, 0x28, 0x1c, 0x15, 0x3a, 0xcc, 0x0c,
0xa9, 0xa6, 0x9e, 0x3b, 0x52, 0xec, 0x3e, 0xd5, 0x82, 0x48, 0x9e, 0xc0, 0xe4, 0x49, 0x33, 0x57,
0x46, 0x63, 0x06, 0x63, 0xae, 0xbe, 0x8e, 0xc4, 0x85, 0x28, 0x76, 0xcb, 0xb6, 0x94, 0x67, 0x30,
0x29, 0xf5, 0xc7, 0x5a, 0xb3, 0x47, 0x84, 0xc4, 0x56, 0x8d, 0x8e, 0x34, 0xd4, 0xf2, 0x14, 0xa6,
0xa5, 0xe6, 0x15, 0x59, 0x0e, 0xc3, 0x0d, 0x9b, 0x7e, 0xb8, 0x61, 0x23, 0x0b, 0xc8, 0x5e, 0xbc,
0xd3, 0x55, 0x53, 0x5b, 0xd3, 0x6f, 0x39, 0x80, 0x9d, 0x39, 0xad, 0xad, 0x0f, 0xba, 0x71, 0xd9,
0x35, 0xf2, 0x0a, 0xf6, 0x7e, 0x29, 0xe3, 0xc2, 0x61, 0xe9, 0x39, 0x24, 0xcf, 0xb5, 0x35, 0x78,
0x08, 0x29, 0x7b, 0x47, 0xef, 0x3a, 0xe2, 0xd8, 0x05, 0x4e, 0x7f, 0xf3, 0x9b, 0x6f, 0x01, 0xe3,
0x47, 0x22, 0xbc, 0x83, 0xe4, 0xa1, 0x5a, 0x2e, 0xf1, 0x58, 0x6d, 0xbe, 0x88, 0x8a, 0x5e, 0xf3,
0x7c, 0x08, 0x75, 0xe6, 0xe4, 0x08, 0x5f, 0x21, 0xed, 0x3c, 0xa3, 0xdc, 0xd6, 0x6d, 0xe6, 0xce,
0x2f, 0xff, 0xd5, 0xf4, 0x4b, 0x67, 0x02, 0xef, 0x61, 0xda, 0xe6, 0xeb, 0x32, 0x6c, 0x0f, 0xb5,
0x2c, 0x1f, 0xba, 0x27, 0x6b, 0xe4, 0xa8, 0x10, 0x33, 0xf1, 0x96, 0x86, 0x9f, 0xbe, 0xfd, 0x09,
0x00, 0x00, 0xff, 0xff, 0x63, 0x62, 0xcb, 0x8c, 0x00, 0x02, 0x00, 0x00,
}

View File

@ -0,0 +1,37 @@
syntax = "proto3";
package go.micro.srv.foo;
service Foo {
rpc Call(Request) returns (Response) {}
rpc Stream(StreamingRequest) returns (stream StreamingResponse) {}
rpc PingPong(stream Ping) returns (stream Pong) {}
}
message Message {
string say = 1;
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
message StreamingRequest {
int64 count = 1;
}
message StreamingResponse {
int64 count = 1;
}
message Ping {
int64 stroke = 1;
}
message Pong {
int64 stroke = 1;
}