Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -22,7 +22,7 @@ import (
|
||||
pb "go.unistack.org/micro-tests/server/combo/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
mregister "go.unistack.org/micro/v3/register/memory"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
@@ -70,7 +70,7 @@ func (h *Handler) Call(ctx context.Context, req *pb.CallReq, rsp *pb.CallRsp) er
|
||||
}
|
||||
|
||||
func TestComboServer(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
reg := mregister.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
h := &Handler{t: t}
|
||||
@@ -111,7 +111,7 @@ func TestComboServer(t *testing.T) {
|
||||
hs := &http.Server{Handler: h2c.NewHandler(newComboMux(hsrv, gsrv.GRPCServer(), nil), &http2.Server{})}
|
||||
|
||||
// init http server
|
||||
if err := hsrv.Init(httpsrv.Server(hs)); err != nil {
|
||||
if err := hsrv.Init(httpsrv.HTTPServer(hs)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,11 @@ package combo
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./proto proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|grpc',standalone=true,debug=true,paths=source_relative:./mgpb proto/proto.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro',standalone=false,debug=true,paths=source_relative:./proto proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|http',standalone=true,debug=true,paths=source_relative:./mhpb proto/proto.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='grpc',standalone=true,debug=true,paths=source_relative:./mgpb proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='http',standalone=true,debug=true,paths=source_relative:./mhpb proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='openapiv3',openapi_file=./apidocs.swagger.yaml,standalone=true,debug=true,paths=source_relative:./proto proto/proto.proto"
|
||||
|
||||
@@ -14,8 +16,6 @@ package combo
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./ndpb proto/proto.proto"
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-drpc_out=json=false,paths=source_relative:./ndpb proto/proto.proto"
|
||||
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|http',standalone=true,debug=true,paths=source_relative:./mhpb proto/proto.proto"
|
||||
|
||||
////go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out=components='micro|drpc',standalone=true,debug=true,paths=source_relative:./mdpb proto/proto.proto"
|
||||
|
||||
//go:generate sh -c "mkdir -p swagger-ui && cp proto/apidocs.swagger.yaml swagger-ui/swagger.yaml && curl -L https://github.com/swagger-api/swagger-ui/archive/refs/tags/v4.17.0.tar.gz -o v4.17.0.tar.gz && tar -C swagger-ui --strip-components=2 -zxvf v4.17.0.tar.gz swagger-ui-4.17.0/dist && rm -f v4.17.0.tar.gz && sed -i '' 's|https://petstore.swagger.io/v2/swagger.json|./swagger.yaml|g' swagger-ui/index.html swagger-ui/swagger-initializer.js && sed -i '' 's|deepLinking: true,|deepLinking: true, displayOperationId: true, tryItOutEnabled: true,|g' swagger-ui/swagger-initializer.js "
|
||||
|
@@ -1,17 +0,0 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.4
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protojson "google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
var (
|
||||
marshaler = protojson.MarshalOptions{}
|
||||
)
|
||||
|
||||
func (m *Error) Error() string {
|
||||
buf, _ := marshaler.Marshal(m)
|
||||
return string(buf)
|
||||
}
|
@@ -37,7 +37,7 @@ func NewTestClient(name string, c client.Client) proto.TestClient {
|
||||
|
||||
func (c *testClient) Call(ctx context.Context, req *proto.CallReq, opts ...client.CallOption) (*proto.CallRsp, error) {
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &proto.Error{}
|
||||
errmap["default"] = &proto.ErrorRsp{}
|
||||
opts = append(opts,
|
||||
v31.ErrorMap(errmap),
|
||||
)
|
||||
|
@@ -22,7 +22,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
@@ -41,7 +41,7 @@ components:
|
||||
properties:
|
||||
rsp:
|
||||
type: string
|
||||
Error:
|
||||
ErrorRsp:
|
||||
type: object
|
||||
properties:
|
||||
err:
|
||||
|
@@ -11,7 +11,7 @@ var (
|
||||
marshaler = protojson.MarshalOptions{}
|
||||
)
|
||||
|
||||
func (m *Error) Error() string {
|
||||
func (m *ErrorRsp) Error() string {
|
||||
buf, _ := marshaler.Marshal(m)
|
||||
return string(buf)
|
||||
}
|
@@ -118,7 +118,7 @@ func (x *CallRsp) GetRsp() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
type ErrorRsp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@@ -126,8 +126,8 @@ type Error struct {
|
||||
Err string `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Error) Reset() {
|
||||
*x = Error{}
|
||||
func (x *ErrorRsp) Reset() {
|
||||
*x = ErrorRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
@@ -135,13 +135,13 @@ func (x *Error) Reset() {
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Error) String() string {
|
||||
func (x *ErrorRsp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Error) ProtoMessage() {}
|
||||
func (*ErrorRsp) ProtoMessage() {}
|
||||
|
||||
func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
func (x *ErrorRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
@@ -153,12 +153,12 @@ func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Error.ProtoReflect.Descriptor instead.
|
||||
func (*Error) Descriptor() ([]byte, []int) {
|
||||
// Deprecated: Use ErrorRsp.ProtoReflect.Descriptor instead.
|
||||
func (*ErrorRsp) Descriptor() ([]byte, []int) {
|
||||
return file_proto_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Error) GetErr() string {
|
||||
func (x *ErrorRsp) GetErr() string {
|
||||
if x != nil {
|
||||
return x.Err
|
||||
}
|
||||
@@ -179,20 +179,20 @@ var file_proto_proto_rawDesc = []byte{
|
||||
0x1b, 0x0a, 0x07, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65,
|
||||
0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x71, 0x22, 0x1b, 0x0a, 0x07,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x73, 0x70, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x73, 0x70, 0x22, 0x19, 0x0a, 0x05, 0x45, 0x72, 0x72,
|
||||
0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x65, 0x72, 0x72, 0x32, 0x77, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x6f, 0x0a, 0x04,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x12, 0x16, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x74,
|
||||
0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c,
|
||||
0x6c, 0x52, 0x73, 0x70, 0x22, 0x37, 0xaa, 0x84, 0x9e, 0x03, 0x22, 0x2a, 0x04, 0x43, 0x61, 0x6c,
|
||||
0x6c, 0x42, 0x1a, 0x0a, 0x18, 0x12, 0x16, 0x0a, 0x14, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0xb2, 0xea, 0xff,
|
||||
0xf9, 0x01, 0x0a, 0x22, 0x05, 0x2f, 0x43, 0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0x42, 0x33, 0x5a,
|
||||
0x31, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6f, 0x72, 0x67,
|
||||
0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x62, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x73, 0x70, 0x22, 0x1c, 0x0a, 0x08, 0x45, 0x72, 0x72,
|
||||
0x6f, 0x72, 0x52, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x03, 0x65, 0x72, 0x72, 0x32, 0x7a, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12,
|
||||
0x72, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x16, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a,
|
||||
0x16, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70, 0x22, 0x3a, 0xaa, 0x84, 0x9e, 0x03, 0x25, 0x2a, 0x04,
|
||||
0x43, 0x61, 0x6c, 0x6c, 0x42, 0x1d, 0x0a, 0x1b, 0x12, 0x19, 0x0a, 0x17, 0x2e, 0x74, 0x65, 0x73,
|
||||
0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x52, 0x73, 0x70, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0a, 0x22, 0x05, 0x2f, 0x43, 0x61, 0x6c, 0x6c,
|
||||
0x3a, 0x01, 0x2a, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61,
|
||||
0x63, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74, 0x65, 0x73,
|
||||
0x74, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x62, 0x6f, 0x2f,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -209,9 +209,9 @@ func file_proto_proto_rawDescGZIP() []byte {
|
||||
|
||||
var file_proto_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_proto_proto_goTypes = []interface{}{
|
||||
(*CallReq)(nil), // 0: test.v1.proto.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.proto.CallRsp
|
||||
(*Error)(nil), // 2: test.v1.proto.Error
|
||||
(*CallReq)(nil), // 0: test.v1.proto.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.proto.CallRsp
|
||||
(*ErrorRsp)(nil), // 2: test.v1.proto.ErrorRsp
|
||||
}
|
||||
var file_proto_proto_depIdxs = []int32{
|
||||
0, // 0: test.v1.proto.Test.Call:input_type -> test.v1.proto.CallReq
|
||||
@@ -254,7 +254,7 @@ func file_proto_proto_init() {
|
||||
}
|
||||
}
|
||||
file_proto_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Error); i {
|
||||
switch v := v.(*ErrorRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
|
@@ -16,7 +16,7 @@ service Test {
|
||||
responses: {
|
||||
default: {
|
||||
reference: {
|
||||
_ref: ".test.v1.proto.Error";
|
||||
_ref: ".test.v1.proto.ErrorRsp";
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -33,6 +33,6 @@ message CallRsp {
|
||||
string rsp = 1;
|
||||
};
|
||||
|
||||
message Error {
|
||||
message ErrorRsp {
|
||||
string err = 1;
|
||||
};
|
||||
|
24
server/combo/proto/proto_micro.pb.go
Normal file
24
server/combo/proto/proto_micro.pb.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.29.2
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
)
|
||||
|
||||
var (
|
||||
TestName = "Test"
|
||||
)
|
||||
|
||||
type TestClient interface {
|
||||
Call(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error)
|
||||
}
|
||||
|
||||
type TestServer interface {
|
||||
Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
|
||||
}
|
@@ -22,7 +22,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
$ref: '#/components/schemas/ErrorRsp'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
@@ -41,7 +41,7 @@ components:
|
||||
properties:
|
||||
rsp:
|
||||
type: string
|
||||
Error:
|
||||
ErrorRsp:
|
||||
type: object
|
||||
properties:
|
||||
err:
|
||||
|
Reference in New Issue
Block a user