[WIP] Moving test services to this repo

This commit is contained in:
Janos Dobronszki
2020-10-02 15:03:48 +02:00
parent 61fe9c169b
commit 5c6ba0dbcd
49 changed files with 10400 additions and 0 deletions

234
example/proto/example.pb.go Normal file
View File

@@ -0,0 +1,234 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.11.4
// source: proto/example.proto
package srv_test_example
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
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)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Request struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Caps bool `protobuf:"varint,2,opt,name=caps,proto3" json:"caps,omitempty"`
Number int64 `protobuf:"varint,3,opt,name=number,proto3" json:"number,omitempty"`
}
func (x *Request) Reset() {
*x = Request{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_example_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Request) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Request) ProtoMessage() {}
func (x *Request) ProtoReflect() protoreflect.Message {
mi := &file_proto_example_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 mi.MessageOf(x)
}
// Deprecated: Use Request.ProtoReflect.Descriptor instead.
func (*Request) Descriptor() ([]byte, []int) {
return file_proto_example_proto_rawDescGZIP(), []int{0}
}
func (x *Request) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Request) GetCaps() bool {
if x != nil {
return x.Caps
}
return false
}
func (x *Request) GetNumber() int64 {
if x != nil {
return x.Number
}
return 0
}
type Response struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
}
func (x *Response) Reset() {
*x = Response{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_example_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Response) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Response) ProtoMessage() {}
func (x *Response) ProtoReflect() protoreflect.Message {
mi := &file_proto_example_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 mi.MessageOf(x)
}
// Deprecated: Use Response.ProtoReflect.Descriptor instead.
func (*Response) Descriptor() ([]byte, []int) {
return file_proto_example_proto_rawDescGZIP(), []int{1}
}
func (x *Response) GetMsg() string {
if x != nil {
return x.Msg
}
return ""
}
var File_proto_example_proto protoreflect.FileDescriptor
var file_proto_example_proto_rawDesc = []byte{
0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x73, 0x72, 0x76, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x5f,
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x22, 0x49, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x61, 0x70, 0x73, 0x18, 0x02,
0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x63, 0x61, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75,
0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62,
0x65, 0x72, 0x22, 0x1c, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10,
0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67,
0x32, 0x4a, 0x0a, 0x07, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x3f, 0x0a, 0x04, 0x43,
0x61, 0x6c, 0x6c, 0x12, 0x19, 0x2e, 0x73, 0x72, 0x76, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x65,
0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a,
0x2e, 0x73, 0x72, 0x76, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c,
0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_example_proto_rawDescOnce sync.Once
file_proto_example_proto_rawDescData = file_proto_example_proto_rawDesc
)
func file_proto_example_proto_rawDescGZIP() []byte {
file_proto_example_proto_rawDescOnce.Do(func() {
file_proto_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_example_proto_rawDescData)
})
return file_proto_example_proto_rawDescData
}
var file_proto_example_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_proto_example_proto_goTypes = []interface{}{
(*Request)(nil), // 0: srv.test_example.Request
(*Response)(nil), // 1: srv.test_example.Response
}
var file_proto_example_proto_depIdxs = []int32{
0, // 0: srv.test_example.Example.Call:input_type -> srv.test_example.Request
1, // 1: srv.test_example.Example.Call:output_type -> srv.test_example.Response
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_proto_example_proto_init() }
func file_proto_example_proto_init() {
if File_proto_example_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_example_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Request); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_example_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); 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_proto_example_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_example_proto_goTypes,
DependencyIndexes: file_proto_example_proto_depIdxs,
MessageInfos: file_proto_example_proto_msgTypes,
}.Build()
File_proto_example_proto = out.File
file_proto_example_proto_rawDesc = nil
file_proto_example_proto_goTypes = nil
file_proto_example_proto_depIdxs = nil
}

View File

@@ -0,0 +1,93 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: proto/example.proto
package srv_test_example
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
api "github.com/micro/go-micro/v3/api"
client "github.com/micro/go-micro/v3/client"
server "github.com/micro/go-micro/v3/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 _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for Example service
func NewExampleEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for Example service
type ExampleService interface {
Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
}
type exampleService struct {
c client.Client
name string
}
func NewExampleService(name string, c client.Client) ExampleService {
return &exampleService{
c: c,
name: name,
}
}
func (c *exampleService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
req := c.c.NewRequest(c.name, "Example.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 Example service
type ExampleHandler interface {
Call(context.Context, *Request, *Response) error
}
func RegisterExampleHandler(s server.Server, hdlr ExampleHandler, opts ...server.HandlerOption) error {
type example interface {
Call(ctx context.Context, in *Request, out *Response) error
}
type Example struct {
example
}
h := &exampleHandler{hdlr}
return s.Handle(s.NewHandler(&Example{h}, opts...))
}
type exampleHandler struct {
ExampleHandler
}
func (h *exampleHandler) Call(ctx context.Context, in *Request, out *Response) error {
return h.ExampleHandler.Call(ctx, in, out)
}

View File

@@ -0,0 +1,17 @@
syntax = "proto3";
package srv.test_example;
service Example {
rpc Call(Request) returns (Response) {}
}
message Request {
string name = 1;
bool caps = 2;
int64 number = 3;
}
message Response {
string msg = 1;
}