add codec frame test generator
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
2a6ba611ed
commit
ed4aeb6d1d
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0-devel
|
||||
// protoc-gen-go v1.26.0-devel
|
||||
// protoc v3.6.1
|
||||
// source: test.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0-devel
|
||||
// protoc-gen-go v1.26.0-devel
|
||||
// protoc v3.6.1
|
||||
// source: github.proto
|
||||
|
||||
|
3
codec/generate.go
Normal file
3
codec/generate.go
Normal file
@ -0,0 +1,3 @@
|
||||
package grpc
|
||||
|
||||
//go:generate protoc -I./proto -I. -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/unistack-org/micro/v3@v3.2.24 -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/unistack-org/micro-proto@v0.0.1 --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto
|
74
codec/proto/test.pb.go
Normal file
74
codec/proto/test.pb.go
Normal file
@ -0,0 +1,74 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0-devel
|
||||
// protoc v3.6.1
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
codec "github.com/unistack-org/micro/v3/codec"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
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)
|
||||
)
|
||||
|
||||
var File_test_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_test_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x68, 0x65,
|
||||
0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x1a, 0x11, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x2f,
|
||||
0x66, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x38, 0x0a, 0x04, 0x54,
|
||||
0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x12, 0x2e, 0x6d, 0x69,
|
||||
0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x1a,
|
||||
0x12, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x2e, 0x46, 0x72,
|
||||
0x61, 0x6d, 0x65, 0x22, 0x00, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, 0x67,
|
||||
0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var file_test_proto_goTypes = []interface{}{
|
||||
(*codec.Frame)(nil), // 0: micro.codec.Frame
|
||||
}
|
||||
var file_test_proto_depIdxs = []int32{
|
||||
0, // 0: helloworld.Test.Call:input_type -> micro.codec.Frame
|
||||
0, // 1: helloworld.Test.Call:output_type -> micro.codec.Frame
|
||||
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_test_proto_init() }
|
||||
func file_test_proto_init() {
|
||||
if File_test_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_test_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 0,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_test_proto_goTypes,
|
||||
DependencyIndexes: file_test_proto_depIdxs,
|
||||
}.Build()
|
||||
File_test_proto = out.File
|
||||
file_test_proto_rawDesc = nil
|
||||
file_test_proto_goTypes = nil
|
||||
file_test_proto_depIdxs = nil
|
||||
}
|
12
codec/proto/test.proto
Normal file
12
codec/proto/test.proto
Normal file
@ -0,0 +1,12 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package helloworld;
|
||||
option go_package = "github.com/unistack-org/micro-tests/codec/proto;pb";
|
||||
|
||||
import "codec/frame.proto";
|
||||
|
||||
|
||||
service Test {
|
||||
rpc Call(micro.codec.Frame) returns (micro.codec.Frame) {}
|
||||
}
|
||||
|
22
codec/proto/test_micro.pb.go
Normal file
22
codec/proto/test_micro.pb.go
Normal file
@ -0,0 +1,22 @@
|
||||
// Code generated by protoc-gen-micro
|
||||
// source: test.proto
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/unistack-org/micro/v3/api"
|
||||
client "github.com/unistack-org/micro/v3/client"
|
||||
codec "github.com/unistack-org/micro/v3/codec"
|
||||
)
|
||||
|
||||
func NewTestEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
type TestClient interface {
|
||||
Call(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error)
|
||||
}
|
||||
|
||||
type TestServer interface {
|
||||
Call(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error
|
||||
}
|
52
codec/proto/test_micro_http.pb.go
Normal file
52
codec/proto/test_micro_http.pb.go
Normal file
@ -0,0 +1,52 @@
|
||||
// Code generated by protoc-gen-micro
|
||||
// source: test.proto
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
_ "github.com/unistack-org/micro-client-http/v3"
|
||||
api "github.com/unistack-org/micro/v3/api"
|
||||
client "github.com/unistack-org/micro/v3/client"
|
||||
codec "github.com/unistack-org/micro/v3/codec"
|
||||
server "github.com/unistack-org/micro/v3/server"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewTestClient(name string, c client.Client) TestClient {
|
||||
return &testClient{c: c, name: name}
|
||||
}
|
||||
|
||||
func (c *testClient) Call(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) {
|
||||
rsp := &codec.Frame{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rsp, nil
|
||||
}
|
||||
|
||||
type testServer struct {
|
||||
TestServer
|
||||
}
|
||||
|
||||
func (h *testServer) Call(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error {
|
||||
return h.TestServer.Call(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
|
||||
type test interface {
|
||||
Call(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error
|
||||
}
|
||||
type Test struct {
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
for _, endpoint := range NewTestEndpoints() {
|
||||
opts = append(opts, api.WithEndpoint(endpoint))
|
||||
}
|
||||
return s.Handle(s.NewHandler(&Test{h}, opts...))
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0-devel
|
||||
// protoc-gen-go v1.26.0-devel
|
||||
// protoc v3.6.1
|
||||
// source: test.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0-devel
|
||||
// protoc-gen-go v1.26.0-devel
|
||||
// protoc v3.6.1
|
||||
// source: test.proto
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0-devel
|
||||
// protoc-gen-go v1.26.0-devel
|
||||
// protoc v3.6.1
|
||||
// source: test.proto
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user