@@ -75,7 +75,7 @@ func TestComboServer(t *testing.T) {
|
||||
|
||||
h := &Handler{t: t}
|
||||
|
||||
_ = logger.DefaultLogger.Init(logger.WithCallerSkipCount(3))
|
||||
_ = logger.DefaultLogger.Init()
|
||||
|
||||
// create grpc server
|
||||
gsrv := grpcsrv.NewServer(
|
||||
|
17
server/combo/mgpb/micro_errors.pb.go
Normal file
17
server/combo/mgpb/micro_errors.pb.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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)
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.2
|
||||
// - protoc v3.21.12
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
)
|
||||
@@ -16,17 +15,6 @@ import (
|
||||
var (
|
||||
TestName = "Test"
|
||||
)
|
||||
var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{
|
||||
{
|
||||
Name: "Test.Call",
|
||||
Path: "/Call",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
type TestClient interface {
|
||||
Call(ctx context.Context, req *proto.CallReq, opts ...client.CallOption) (*proto.CallRsp, error)
|
||||
|
@@ -1,12 +1,11 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.2
|
||||
// protoc-gen-go-micro version: v3.10.4
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
@@ -17,7 +16,7 @@ type testClient struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func NewTestClient(name string, c client.Client) TestClient {
|
||||
func NewTestClient(name string, c client.Client) proto.TestClient {
|
||||
return &testClient{c: c, name: name}
|
||||
}
|
||||
|
||||
@@ -31,14 +30,14 @@ func (c *testClient) Call(ctx context.Context, req *proto.CallReq, opts ...clien
|
||||
}
|
||||
|
||||
type testServer struct {
|
||||
TestServer
|
||||
proto.TestServer
|
||||
}
|
||||
|
||||
func (h *testServer) Call(ctx context.Context, req *proto.CallReq, rsp *proto.CallRsp) error {
|
||||
return h.TestServer.Call(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
|
||||
func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.HandlerOption) error {
|
||||
type test interface {
|
||||
Call(ctx context.Context, req *proto.CallReq, rsp *proto.CallRsp) error
|
||||
}
|
||||
@@ -47,6 +46,5 @@ func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOp
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
}
|
||||
|
17
server/combo/mhpb/micro_errors.pb.go
Normal file
17
server/combo/mhpb/micro_errors.pb.go
Normal file
@@ -0,0 +1,17 @@
|
||||
// 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)
|
||||
}
|
@@ -1,14 +1,13 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.2
|
||||
// - protoc v3.21.12
|
||||
// - protoc-gen-go-micro v3.10.4
|
||||
// - protoc v5.28.3
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
)
|
||||
@@ -16,17 +15,6 @@ import (
|
||||
var (
|
||||
TestName = "Test"
|
||||
)
|
||||
var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{
|
||||
{
|
||||
Name: "Test.Call",
|
||||
Path: "/Call",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
type TestClient interface {
|
||||
Call(ctx context.Context, req *proto.CallReq, opts ...client.CallOption) (*proto.CallRsp, error)
|
||||
|
@@ -1,25 +1,37 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.2
|
||||
// protoc-gen-go-micro version: v3.10.4
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
v3 "go.unistack.org/micro-client-http/v3"
|
||||
v31 "go.unistack.org/micro-server-http/v3"
|
||||
v31 "go.unistack.org/micro-client-http/v3"
|
||||
v3 "go.unistack.org/micro-server-http/v3"
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
http "net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{
|
||||
{
|
||||
Name: "Test.Call",
|
||||
Path: "/Call",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewTestClient(name string, c client.Client) TestClient {
|
||||
func NewTestClient(name string, c client.Client) proto.TestClient {
|
||||
return &testClient{c: c, name: name}
|
||||
}
|
||||
|
||||
@@ -27,12 +39,12 @@ func (c *testClient) Call(ctx context.Context, req *proto.CallReq, opts ...clien
|
||||
errmap := make(map[string]interface{}, 1)
|
||||
errmap["default"] = &proto.Error{}
|
||||
opts = append(opts,
|
||||
v3.ErrorMap(errmap),
|
||||
v31.ErrorMap(errmap),
|
||||
)
|
||||
opts = append(opts,
|
||||
v3.Method(http.MethodPost),
|
||||
v3.Path("/Call"),
|
||||
v3.Body("*"),
|
||||
v31.Method(http.MethodPost),
|
||||
v31.Path("/Call"),
|
||||
v31.Body("*"),
|
||||
)
|
||||
rsp := &proto.CallRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
|
||||
@@ -43,14 +55,14 @@ func (c *testClient) Call(ctx context.Context, req *proto.CallReq, opts ...clien
|
||||
}
|
||||
|
||||
type testServer struct {
|
||||
TestServer
|
||||
proto.TestServer
|
||||
}
|
||||
|
||||
func (h *testServer) Call(ctx context.Context, req *proto.CallReq, rsp *proto.CallRsp) error {
|
||||
return h.TestServer.Call(ctx, req, rsp)
|
||||
}
|
||||
|
||||
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
|
||||
func RegisterTestServer(s server.Server, sh proto.TestServer, opts ...server.HandlerOption) error {
|
||||
type test interface {
|
||||
Call(ctx context.Context, req *proto.CallReq, rsp *proto.CallRsp) error
|
||||
}
|
||||
@@ -59,6 +71,6 @@ func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOp
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v31.HandlerEndpoints(TestServerEndpoints))
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.21.12
|
||||
// protoc v5.28.3
|
||||
// source: ngpb.proto
|
||||
|
||||
package pb
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v3.21.12
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.28.3
|
||||
// source: ngpb.proto
|
||||
|
||||
package pb
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Test_Call_FullMethodName = "/test.v1.ngpb.Test/Call"
|
||||
@@ -39,8 +39,9 @@ func NewTestClient(cc grpc.ClientConnInterface) TestClient {
|
||||
}
|
||||
|
||||
func (c *testClient) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*CallRsp, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(CallRsp)
|
||||
err := c.cc.Invoke(ctx, Test_Call_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, Test_Call_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -49,21 +50,25 @@ func (c *testClient) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOpt
|
||||
|
||||
// TestServer is the server API for Test service.
|
||||
// All implementations must embed UnimplementedTestServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type TestServer interface {
|
||||
// option (micro.api.micro_service) = { client_wrappers: ["one","two"]; };
|
||||
Call(context.Context, *CallReq) (*CallRsp, error)
|
||||
mustEmbedUnimplementedTestServer()
|
||||
}
|
||||
|
||||
// UnimplementedTestServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedTestServer struct {
|
||||
}
|
||||
// UnimplementedTestServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedTestServer struct{}
|
||||
|
||||
func (UnimplementedTestServer) Call(context.Context, *CallReq) (*CallRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
|
||||
}
|
||||
func (UnimplementedTestServer) mustEmbedUnimplementedTestServer() {}
|
||||
func (UnimplementedTestServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeTestServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to TestServer will
|
||||
@@ -73,6 +78,13 @@ type UnsafeTestServer interface {
|
||||
}
|
||||
|
||||
func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer) {
|
||||
// If the following call pancis, it indicates UnimplementedTestServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&Test_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.21.12
|
||||
// protoc v5.28.3
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
Reference in New Issue
Block a user