add combo test example
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
09f5a71e0b
commit
288d16a6f0
360
server/combo/combo_old_test.go
Normal file
360
server/combo/combo_old_test.go
Normal file
@ -0,0 +1,360 @@
|
||||
//go:build ignore
|
||||
|
||||
package combo_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
// drpccli "go.unistack.org/micro-client-drpc/v3"
|
||||
grpccli "go.unistack.org/micro-client-grpc/v3"
|
||||
httpcli "go.unistack.org/micro-client-http/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
// mdpb "go.unistack.org/micro-tests/server/combo/mdpb"
|
||||
mgpb "go.unistack.org/micro-tests/server/combo/mgpb"
|
||||
mhpb "go.unistack.org/micro-tests/server/combo/mhpb"
|
||||
|
||||
// ndpb "go.unistack.org/micro-tests/server/combo/ndpb"
|
||||
ngpb "go.unistack.org/micro-tests/server/combo/ngpb"
|
||||
pb "go.unistack.org/micro-tests/server/combo/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/encoding"
|
||||
gmetadata "google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/peer"
|
||||
"google.golang.org/grpc/status"
|
||||
//"storj.io/drpc"
|
||||
//"storj.io/drpc/drpcconn"
|
||||
//"storj.io/drpc/drpchttp"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
const (
|
||||
grpcDefaultContentType = "application/grpc+proto"
|
||||
// drpcDefaultContentType = "application/drpc+proto"
|
||||
httpDefaultContentType = "application/json"
|
||||
)
|
||||
|
||||
type wrapMicroCodec struct{ codec.Codec }
|
||||
|
||||
func (w *wrapMicroCodec) Name() string {
|
||||
return w.Codec.String()
|
||||
}
|
||||
|
||||
func (w *wrapMicroCodec) Marshal(v interface{}) ([]byte, error) {
|
||||
return w.Codec.Marshal(v)
|
||||
}
|
||||
|
||||
func (w *wrapMicroCodec) Unmarshal(d []byte, v interface{}) error {
|
||||
return w.Codec.Unmarshal(d, v)
|
||||
}
|
||||
|
||||
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// ctx := r.Context()
|
||||
w.Header().Add("Content-Type", httpDefaultContentType)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = jsonpbcodec.NewCodec().Write(w, nil, &pb.CallRsp{Rsp: "name_my_name"})
|
||||
}
|
||||
|
||||
func (h *Handler) ServeGRPC(_ interface{}, stream grpc.ServerStream) error {
|
||||
ctx := stream.Context()
|
||||
|
||||
fullMethod, ok := grpc.MethodFromServerStream(stream)
|
||||
if !ok {
|
||||
return status.Errorf(codes.Internal, "method does not exist in context")
|
||||
}
|
||||
|
||||
serviceName, methodName, err := grpcServiceMethod(fullMethod)
|
||||
if err != nil {
|
||||
return status.New(codes.InvalidArgument, err.Error()).Err()
|
||||
}
|
||||
_, _ = serviceName, methodName
|
||||
// get grpc metadata
|
||||
gmd, ok := gmetadata.FromIncomingContext(stream.Context())
|
||||
if !ok {
|
||||
gmd = gmetadata.MD{}
|
||||
}
|
||||
|
||||
md := metadata.New(len(gmd))
|
||||
for k, v := range gmd {
|
||||
md.Set(k, strings.Join(v, ", "))
|
||||
}
|
||||
|
||||
// timeout for server deadline
|
||||
to, ok := md.Get("timeout")
|
||||
if ok {
|
||||
md.Del("timeout")
|
||||
}
|
||||
|
||||
// get content type
|
||||
ct := grpcDefaultContentType
|
||||
|
||||
if ctype, ok := md.Get("content-type"); ok {
|
||||
ct = ctype
|
||||
} else if ctype, ok := md.Get("x-content-type"); ok {
|
||||
ct = ctype
|
||||
md.Del("x-content-type")
|
||||
}
|
||||
|
||||
_ = ct
|
||||
|
||||
// get peer from context
|
||||
if p, ok := peer.FromContext(ctx); ok {
|
||||
md["Remote"] = p.Addr.String()
|
||||
ctx = peer.NewContext(ctx, p)
|
||||
}
|
||||
|
||||
// create new context
|
||||
ctx = metadata.NewIncomingContext(ctx, md)
|
||||
|
||||
// set the timeout if we have it
|
||||
if len(to) > 0 {
|
||||
if n, err := strconv.ParseUint(to, 10, 64); err == nil {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, time.Duration(n))
|
||||
defer cancel()
|
||||
}
|
||||
}
|
||||
|
||||
frame := &codec.Frame{}
|
||||
if err := stream.RecvMsg(frame); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// logger.Infof(ctx, "frame: %s", frame.Data)
|
||||
|
||||
if err := stream.SendMsg(&pb.CallRsp{Rsp: "name_my_name"}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func grpcServiceMethod(m string) (string, string, error) {
|
||||
if len(m) == 0 {
|
||||
return "", "", fmt.Errorf("malformed method name: %q", m)
|
||||
}
|
||||
|
||||
// grpc method
|
||||
if m[0] == '/' {
|
||||
// [ , Foo, Bar]
|
||||
// [ , package.Foo, Bar]
|
||||
// [ , a.package.Foo, Bar]
|
||||
parts := strings.Split(m, "/")
|
||||
if len(parts) != 3 || len(parts[1]) == 0 || len(parts[2]) == 0 {
|
||||
return "", "", fmt.Errorf("malformed method name: %q", m)
|
||||
}
|
||||
service := strings.Split(parts[1], ".")
|
||||
return service[len(service)-1], parts[2], nil
|
||||
}
|
||||
|
||||
// non grpc method
|
||||
parts := strings.Split(m, ".")
|
||||
|
||||
// expect [Foo, Bar]
|
||||
if len(parts) != 2 {
|
||||
return "", "", fmt.Errorf("malformed method name: %q", m)
|
||||
}
|
||||
|
||||
return parts[0], parts[1], nil
|
||||
}
|
||||
|
||||
/*
|
||||
func (h *Handler) ServeDRPC(stream drpc.Stream, rpc string) error {
|
||||
ctx := stream.Context()
|
||||
logger.Infof(ctx, "drpc: %#+v", rpc)
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
func (h *Handler) HandleRPC(stream drpc.Stream, rpc string) error {
|
||||
return h.ServeDRPC(stream, rpc)
|
||||
}
|
||||
*/
|
||||
|
||||
func TestComboServer(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
ctx := context.Background()
|
||||
|
||||
h := &Handler{t: t}
|
||||
|
||||
_ = logger.DefaultLogger.Init(logger.WithCallerSkipCount(3))
|
||||
encoding.RegisterCodec(&wrapMicroCodec{protocodec.NewCodec()})
|
||||
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf(":0"))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
gsrv := grpc.NewServer(grpc.UnknownServiceHandler(h.ServeGRPC))
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
if err := gsrv.Serve(lis); err != nil {
|
||||
log.Fatalf("failed to serve: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
comboHandler := newComboMux(h, gsrv, nil) // drpchttp.New(h))
|
||||
http2Server := &http2.Server{}
|
||||
hs := &http.Server{Handler: h2c.NewHandler(comboHandler, http2Server)}
|
||||
|
||||
// create server
|
||||
srv := httpsrv.NewServer(
|
||||
server.Address("127.0.0.1:0"),
|
||||
server.Name("helloworld"),
|
||||
server.Register(reg),
|
||||
httpsrv.Server(hs),
|
||||
)
|
||||
|
||||
// init server
|
||||
if err := srv.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// start server
|
||||
if err := srv.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// lookup server
|
||||
service, err := reg.LookupService(ctx, "helloworld")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(service) != 1 {
|
||||
t.Fatalf("Expected 1 service got %d: %+v", len(service), service)
|
||||
}
|
||||
|
||||
if len(service[0].Nodes) != 1 {
|
||||
t.Fatalf("Expected 1 node got %d: %+v", len(service[0].Nodes), service[0].Nodes)
|
||||
}
|
||||
|
||||
mhcli := client.NewClientCallOptions(httpcli.NewClient(client.ContentType(httpDefaultContentType), client.Codec(httpDefaultContentType, jsonpbcodec.NewCodec())), client.WithAddress("http://"+service[0].Nodes[0].Address))
|
||||
|
||||
mhttpsvc := mhpb.NewTestClient("helloworld", mhcli)
|
||||
|
||||
mgcli := client.NewClientCallOptions(grpccli.NewClient(client.ContentType(grpcDefaultContentType), client.Codec(grpcDefaultContentType, protocodec.NewCodec())), client.WithAddress("http://"+service[0].Nodes[0].Address))
|
||||
|
||||
mgrpcsvc := mgpb.NewTestClient("helloworld", mgcli)
|
||||
|
||||
// mdcli := client.NewClientCallOptions(drpccli.NewClient(client.ContentType(drpcDefaultContentType), client.Codec(drpcDefaultContentType, protocodec.NewCodec())), client.WithAddress("http://"+service[0].Nodes[0].Address))
|
||||
|
||||
// mdrpcsvc := mdpb.NewTestClient("helloworld", mdcli)
|
||||
|
||||
t.Logf("call via micro grpc")
|
||||
rsp, err := mgrpcsvc.Call(ctx, &pb.CallReq{Req: "my_name"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
}
|
||||
|
||||
ngcli, err := grpc.DialContext(ctx, service[0].Nodes[0].Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer ngcli.Close()
|
||||
|
||||
ngrpcsvc := ngpb.NewTestClient(ngcli)
|
||||
t.Logf("call via native grpc")
|
||||
if rsp, err := ngrpcsvc.Call(ctx, &ngpb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
}
|
||||
|
||||
t.Logf("call via micro http")
|
||||
if rsp, err := mhttpsvc.Call(ctx, &pb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
tc, err := net.Dial("tcp", service[0].Nodes[0].Address)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ndcli := drpcconn.New(tc)
|
||||
defer ndcli.Close()
|
||||
/*
|
||||
ndrpcsvc := ndpb.NewDRPCTestClient(ndcli)
|
||||
|
||||
t.Logf("call via native drpc")
|
||||
if rsp, err := ndrpcsvc.Call(context.TODO(), &ndpb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Logf("native drpc err: %v", err)
|
||||
// t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
}
|
||||
|
||||
t.Logf("call via micro drpc")
|
||||
if rsp, err = mdrpcsvc.Call(ctx, &pb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Logf("micro drpc err: %v", err)
|
||||
// t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
func newComboMux(httph http.Handler, grpch http.Handler, drpch http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.ProtoMajor == 2 {
|
||||
ct := r.Header.Get("content-type")
|
||||
switch {
|
||||
case strings.HasPrefix(ct, "application/grpc"):
|
||||
if grpch != nil {
|
||||
grpch.ServeHTTP(w, r)
|
||||
}
|
||||
return
|
||||
case strings.HasPrefix(ct, "application/drpc"):
|
||||
if drpch != nil {
|
||||
drpch.ServeHTTP(w, r)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
httph.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
@ -1,199 +1,72 @@
|
||||
package combo_test
|
||||
|
||||
/*
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
drpccli "go.unistack.org/micro-client-drpc/v3"
|
||||
grpccli "go.unistack.org/micro-client-grpc/v3"
|
||||
httpcli "go.unistack.org/micro-client-http/v3"
|
||||
jsonpbcodec "go.unistack.org/micro-codec-jsonpb/v3"
|
||||
protocodec "go.unistack.org/micro-codec-proto/v3"
|
||||
grpcsrv "go.unistack.org/micro-server-grpc/v3"
|
||||
httpsrv "go.unistack.org/micro-server-http/v3"
|
||||
mdpb "go.unistack.org/micro-tests/server/combo/mdpb"
|
||||
mgpb "go.unistack.org/micro-tests/server/combo/mgpb"
|
||||
mhpb "go.unistack.org/micro-tests/server/combo/mhpb"
|
||||
|
||||
// ndpb "go.unistack.org/micro-tests/server/combo/ndpb"
|
||||
// ngpb "go.unistack.org/micro-tests/server/combo/ngpb"
|
||||
ngpb "go.unistack.org/micro-tests/server/combo/ngpb"
|
||||
pb "go.unistack.org/micro-tests/server/combo/proto"
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
"go.unistack.org/micro/v3/register"
|
||||
"go.unistack.org/micro/v3/server"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/encoding"
|
||||
gmetadata "google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/peer"
|
||||
"google.golang.org/grpc/status"
|
||||
"storj.io/drpc"
|
||||
"storj.io/drpc/drpcconn"
|
||||
"storj.io/drpc/drpchttp"
|
||||
)
|
||||
|
||||
//go:embed swagger-ui
|
||||
var assets embed.FS
|
||||
|
||||
type Handler struct {
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
const (
|
||||
grpcDefaultContentType = "application/grpc+proto"
|
||||
drpcDefaultContentType = "application/drpc+proto"
|
||||
httpDefaultContentType = "application/json"
|
||||
)
|
||||
|
||||
type wrapMicroCodec struct{ codec.Codec }
|
||||
|
||||
func (w *wrapMicroCodec) Name() string {
|
||||
return w.Codec.String()
|
||||
}
|
||||
|
||||
func (w *wrapMicroCodec) Marshal(v interface{}) ([]byte, error) {
|
||||
return w.Codec.Marshal(v)
|
||||
}
|
||||
|
||||
func (w *wrapMicroCodec) Unmarshal(d []byte, v interface{}) error {
|
||||
return w.Codec.Unmarshal(d, v)
|
||||
}
|
||||
|
||||
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// ctx := r.Context()
|
||||
w.Header().Add("Content-Type", httpDefaultContentType)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = jsonpbcodec.NewCodec().Write(w, nil, &pb.CallRsp{Rsp: "name_my_name"})
|
||||
}
|
||||
|
||||
func (h *Handler) ServeGRPC(_ interface{}, stream grpc.ServerStream) error {
|
||||
ctx := stream.Context()
|
||||
|
||||
fullMethod, ok := grpc.MethodFromServerStream(stream)
|
||||
if !ok {
|
||||
return status.Errorf(codes.Internal, "method does not exist in context")
|
||||
}
|
||||
|
||||
serviceName, methodName, err := grpcServiceMethod(fullMethod)
|
||||
if err != nil {
|
||||
return status.New(codes.InvalidArgument, err.Error()).Err()
|
||||
}
|
||||
_, _ = serviceName, methodName
|
||||
// get grpc metadata
|
||||
gmd, ok := gmetadata.FromIncomingContext(stream.Context())
|
||||
if !ok {
|
||||
gmd = gmetadata.MD{}
|
||||
}
|
||||
|
||||
md := metadata.New(len(gmd))
|
||||
for k, v := range gmd {
|
||||
md.Set(k, strings.Join(v, ", "))
|
||||
}
|
||||
|
||||
// timeout for server deadline
|
||||
to, ok := md.Get("timeout")
|
||||
if ok {
|
||||
md.Del("timeout")
|
||||
}
|
||||
|
||||
// get content type
|
||||
ct := grpcDefaultContentType
|
||||
|
||||
if ctype, ok := md.Get("content-type"); ok {
|
||||
ct = ctype
|
||||
} else if ctype, ok := md.Get("x-content-type"); ok {
|
||||
ct = ctype
|
||||
md.Del("x-content-type")
|
||||
}
|
||||
|
||||
_ = ct
|
||||
|
||||
// get peer from context
|
||||
if p, ok := peer.FromContext(ctx); ok {
|
||||
md["Remote"] = p.Addr.String()
|
||||
ctx = peer.NewContext(ctx, p)
|
||||
}
|
||||
|
||||
// create new context
|
||||
ctx = metadata.NewIncomingContext(ctx, md)
|
||||
|
||||
// set the timeout if we have it
|
||||
if len(to) > 0 {
|
||||
if n, err := strconv.ParseUint(to, 10, 64); err == nil {
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, time.Duration(n))
|
||||
defer cancel()
|
||||
func newComboMux(httph http.Handler, grpch http.Handler, drpch http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.ProtoMajor == 2 {
|
||||
ct := r.Header.Get("content-type")
|
||||
switch {
|
||||
case strings.HasPrefix(ct, "application/grpc"):
|
||||
if grpch != nil {
|
||||
grpch.ServeHTTP(w, r)
|
||||
}
|
||||
return
|
||||
case strings.HasPrefix(ct, "application/drpc"):
|
||||
if drpch != nil {
|
||||
drpch.ServeHTTP(w, r)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
frame := &codec.Frame{}
|
||||
if err := stream.RecvMsg(frame); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// logger.Infof(ctx, "frame: %s", frame.Data)
|
||||
|
||||
if err := stream.SendMsg(&pb.CallRsp{Rsp: "name_my_name"}); err != nil {
|
||||
return err
|
||||
}
|
||||
httph.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func (h *Handler) Call(ctx context.Context, req *pb.CallReq, rsp *pb.CallRsp) error {
|
||||
rsp.Rsp = "name_my_name"
|
||||
return nil
|
||||
}
|
||||
|
||||
func grpcServiceMethod(m string) (string, string, error) {
|
||||
if len(m) == 0 {
|
||||
return "", "", fmt.Errorf("malformed method name: %q", m)
|
||||
}
|
||||
|
||||
// grpc method
|
||||
if m[0] == '/' {
|
||||
// [ , Foo, Bar]
|
||||
// [ , package.Foo, Bar]
|
||||
// [ , a.package.Foo, Bar]
|
||||
parts := strings.Split(m, "/")
|
||||
if len(parts) != 3 || len(parts[1]) == 0 || len(parts[2]) == 0 {
|
||||
return "", "", fmt.Errorf("malformed method name: %q", m)
|
||||
}
|
||||
service := strings.Split(parts[1], ".")
|
||||
return service[len(service)-1], parts[2], nil
|
||||
}
|
||||
|
||||
// non grpc method
|
||||
parts := strings.Split(m, ".")
|
||||
|
||||
// expect [Foo, Bar]
|
||||
if len(parts) != 2 {
|
||||
return "", "", fmt.Errorf("malformed method name: %q", m)
|
||||
}
|
||||
|
||||
return parts[0], parts[1], nil
|
||||
}
|
||||
|
||||
func (h *Handler) ServeDRPC(stream drpc.Stream, rpc string) error {
|
||||
ctx := stream.Context()
|
||||
logger.Infof(ctx, "drpc: %#+v", rpc)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) ServeWS(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
logger.Infof(ctx, "ws: %#+v", r)
|
||||
}
|
||||
|
||||
func (h *Handler) HandleRPC(stream drpc.Stream, rpc string) error {
|
||||
return h.ServeDRPC(stream, rpc)
|
||||
}
|
||||
|
||||
func TestComboServer(t *testing.T) {
|
||||
reg := register.NewRegister()
|
||||
ctx := context.Background()
|
||||
@ -201,29 +74,51 @@ func TestComboServer(t *testing.T) {
|
||||
h := &Handler{t: t}
|
||||
|
||||
_ = logger.DefaultLogger.Init(logger.WithCallerSkipCount(3))
|
||||
encoding.RegisterCodec(&wrapMicroCodec{protocodec.NewCodec()})
|
||||
|
||||
gsrv := grpc.NewServer(grpc.UnknownServiceHandler(h.ServeGRPC))
|
||||
// create grpc server
|
||||
gsrv := grpcsrv.NewServer(
|
||||
server.Name("helloworld"),
|
||||
server.Register(reg),
|
||||
server.Codec("application/json", jsonpbcodec.NewCodec()),
|
||||
server.Codec("application/grpc", protocodec.NewCodec()),
|
||||
server.Codec("application/grpc+proto", protocodec.NewCodec()),
|
||||
server.Codec("application/grpc+json", jsonpbcodec.NewCodec()),
|
||||
)
|
||||
|
||||
comboHandler := newComboMux(h, gsrv, drpchttp.New(h))
|
||||
http2Server := &http2.Server{}
|
||||
hs := &http.Server{Handler: h2c.NewHandler(comboHandler, http2Server)}
|
||||
// init grpc server
|
||||
if err := gsrv.Init(); err != nil {
|
||||
t.Fatalf("grpc err: %v", err)
|
||||
}
|
||||
|
||||
// create server
|
||||
srv := httpsrv.NewServer(
|
||||
if err := mgpb.RegisterTestServer(gsrv, h); err != nil {
|
||||
t.Fatalf("grpc err: %v", err)
|
||||
}
|
||||
|
||||
swaggerdir, _ := fs.Sub(assets, "swagger-ui")
|
||||
|
||||
// create http server
|
||||
hsrv := httpsrv.NewServer(
|
||||
server.Address("127.0.0.1:0"),
|
||||
server.Name("helloworld"),
|
||||
server.Register(reg),
|
||||
httpsrv.Server(hs),
|
||||
server.Codec("application/json", jsonpbcodec.NewCodec()),
|
||||
httpsrv.PathHandler(http.MethodGet, "/swagger-ui/*", http.StripPrefix("/swagger-ui", http.FileServer(http.FS(swaggerdir))).ServeHTTP),
|
||||
)
|
||||
|
||||
// init server
|
||||
if err := srv.Init(); err != nil {
|
||||
// fill http server handler struct
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// start server
|
||||
if err := srv.Start(); err != nil {
|
||||
if err := mhpb.RegisterTestServer(hsrv, h); err != nil {
|
||||
t.Fatalf("grpc err: %v", err)
|
||||
}
|
||||
|
||||
// start http server
|
||||
if err := hsrv.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@ -249,10 +144,6 @@ func TestComboServer(t *testing.T) {
|
||||
|
||||
mgrpcsvc := mgpb.NewTestClient("helloworld", mgcli)
|
||||
|
||||
mdcli := client.NewClientCallOptions(drpccli.NewClient(client.ContentType(drpcDefaultContentType), client.Codec(drpcDefaultContentType, protocodec.NewCodec())), client.WithAddress("http://"+service[0].Nodes[0].Address))
|
||||
|
||||
mdrpcsvc := mdpb.NewTestClient("helloworld", mdcli)
|
||||
|
||||
t.Logf("call via micro grpc")
|
||||
rsp, err := mgrpcsvc.Call(ctx, &pb.CallReq{Req: "my_name"})
|
||||
if err != nil {
|
||||
@ -263,34 +154,21 @@ func TestComboServer(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf(":0"))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
s := grpc.NewServer()
|
||||
pb.RegisterGreeterServer(s, &server{})
|
||||
log.Printf("server listening at %v", lis.Addr())
|
||||
if err := s.Serve(lis); err != nil {
|
||||
log.Fatalf("failed to serve: %v", err)
|
||||
}
|
||||
|
||||
ngcli, err := grpc.DialContext(ctx, service[0].Nodes[0].Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer ngcli.Close()
|
||||
|
||||
/*
|
||||
ngrpcsvc := ngpb.NewTestClient(ngcli)
|
||||
t.Logf("call via native grpc")
|
||||
if rsp, err := ngrpcsvc.Call(ctx, &ngpb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
ngrpcsvc := ngpb.NewTestClient(ngcli)
|
||||
t.Logf("call via native grpc")
|
||||
if rsp, err := ngrpcsvc.Call(ctx, &ngpb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
t.Logf("call via micro http")
|
||||
if rsp, err := mhttpsvc.Call(ctx, &pb.CallReq{Req: "my_name"}); err != nil {
|
||||
@ -301,62 +179,5 @@ func TestComboServer(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
tc, err := net.Dial("tcp", service[0].Nodes[0].Address)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ndcli := drpcconn.New(tc)
|
||||
defer ndcli.Close()
|
||||
/*
|
||||
ndrpcsvc := ndpb.NewDRPCTestClient(ndcli)
|
||||
|
||||
t.Logf("call via native drpc")
|
||||
if rsp, err := ndrpcsvc.Call(context.TODO(), &ndpb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Logf("native drpc err: %v", err)
|
||||
// t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
}
|
||||
|
||||
t.Logf("call via micro drpc")
|
||||
if rsp, err = mdrpcsvc.Call(ctx, &pb.CallReq{Req: "my_name"}); err != nil {
|
||||
t.Logf("micro drpc err: %v", err)
|
||||
// t.Fatal(err)
|
||||
} else {
|
||||
if rsp.Rsp != "name_my_name" {
|
||||
t.Fatalf("invalid response: %#+v\n", rsp)
|
||||
}
|
||||
}
|
||||
select {}
|
||||
}
|
||||
|
||||
func newComboMux(httph http.Handler, grpch http.Handler, drpch http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.ProtoMajor == 2 {
|
||||
ct := r.Header.Get("content-type")
|
||||
switch {
|
||||
case strings.HasPrefix(ct, "application/grpc"):
|
||||
grpch.ServeHTTP(w, r)
|
||||
return
|
||||
case strings.HasPrefix(ct, "application/drpc"):
|
||||
drpch.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
ws := false
|
||||
for _, header := range r.Header["Upgrade"] {
|
||||
if header == "websocket" {
|
||||
ws = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if ws {
|
||||
httph.(*Handler).ServeWS(w, r)
|
||||
return
|
||||
}
|
||||
httph.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
*/
|
||||
|
@ -1,15 +1,21 @@
|
||||
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/test.proto"
|
||||
//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|http',standalone=true,debug=true,paths=source_relative:./mhpb proto/test.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|grpc',standalone=true,debug=true,paths=source_relative:./mgpb proto/test.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/test.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"
|
||||
|
||||
//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:./ngpb proto/test.proto"
|
||||
//go:generate sh -c "protoc -I./proto -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-grpc_out=paths=source_relative:./ngpb proto/test.proto"
|
||||
//go:generate sh -c "protoc -I./ngpb -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go_out=paths=source_relative:./ngpb ngpb/ngpb.proto"
|
||||
//go:generate sh -c "protoc -I./ngpb -I. -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-grpc_out=paths=source_relative:./ngpb ngpb/ngpb.proto"
|
||||
|
||||
//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/test.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/test.proto"
|
||||
////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,59 +0,0 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.1
|
||||
// source: test.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"
|
||||
time "time"
|
||||
)
|
||||
|
||||
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 *proto.CallReq, opts ...client.CallOption) (*proto.CallRsp, error) {
|
||||
td := time.Duration(5000000000)
|
||||
opts = append(opts, client.WithRequestTimeout(td))
|
||||
rsp := &proto.CallRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "test.v1.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 *proto.CallReq, rsp *proto.CallRsp) error {
|
||||
var cancel context.CancelFunc
|
||||
td := time.Duration(5000000000)
|
||||
ctx, cancel = context.WithTimeout(ctx, td)
|
||||
defer cancel()
|
||||
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 *proto.CallReq, rsp *proto.CallRsp) error
|
||||
}
|
||||
type Test struct {
|
||||
test
|
||||
}
|
||||
h := &testServer{sh}
|
||||
var nopts []server.HandlerOption
|
||||
nopts = append(nopts, v3.HandlerEndpoints(TestServerEndpoints))
|
||||
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.1
|
||||
// - protoc-gen-go-micro v3.10.2
|
||||
// - protoc v3.21.12
|
||||
// source: test.proto
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
@ -20,7 +20,7 @@ var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{
|
||||
{
|
||||
Name: "Test.Call",
|
||||
Path: "/v1/call",
|
||||
Path: "/Call",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.1
|
||||
// source: test.proto
|
||||
// protoc-gen-go-micro version: v3.10.2
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
proto "go.unistack.org/micro-tests/server/combo/proto"
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
time "time"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
@ -23,8 +22,6 @@ func NewTestClient(name string, c client.Client) TestClient {
|
||||
}
|
||||
|
||||
func (c *testClient) Call(ctx context.Context, req *proto.CallReq, opts ...client.CallOption) (*proto.CallRsp, error) {
|
||||
td := time.Duration(5000000000)
|
||||
opts = append(opts, client.WithRequestTimeout(td))
|
||||
rsp := &proto.CallRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
|
||||
if err != nil {
|
||||
@ -38,10 +35,6 @@ type testServer struct {
|
||||
}
|
||||
|
||||
func (h *testServer) Call(ctx context.Context, req *proto.CallReq, rsp *proto.CallRsp) error {
|
||||
var cancel context.CancelFunc
|
||||
td := time.Duration(5000000000)
|
||||
ctx, cancel = context.WithTimeout(ctx, td)
|
||||
defer cancel()
|
||||
return h.TestServer.Call(ctx, req, rsp)
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.1
|
||||
// - protoc v3.21.12
|
||||
// source: test.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"
|
||||
)
|
||||
|
||||
var (
|
||||
TestName = "Test"
|
||||
)
|
||||
var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{
|
||||
{
|
||||
Name: "Test.Call",
|
||||
Path: "/v1/call",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
type TestClient interface {
|
||||
Call(ctx context.Context, req *proto.CallReq, opts ...client.CallOption) (*proto.CallRsp, error)
|
||||
}
|
||||
|
||||
type TestServer interface {
|
||||
Call(ctx context.Context, req *proto.CallReq, rsp *proto.CallRsp) error
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-micro v3.10.1
|
||||
// - protoc-gen-go-micro v3.10.2
|
||||
// - protoc v3.21.12
|
||||
// source: test.proto
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
@ -20,7 +20,7 @@ var (
|
||||
TestServerEndpoints = []v3.EndpointMetadata{
|
||||
{
|
||||
Name: "Test.Call",
|
||||
Path: "/v1/call",
|
||||
Path: "/Call",
|
||||
Method: "POST",
|
||||
Body: "*",
|
||||
Stream: false,
|
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||||
// protoc-gen-go-micro version: v3.10.1
|
||||
// source: test.proto
|
||||
// protoc-gen-go-micro version: v3.10.2
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
@ -12,7 +12,6 @@ import (
|
||||
client "go.unistack.org/micro/v3/client"
|
||||
server "go.unistack.org/micro/v3/server"
|
||||
http "net/http"
|
||||
time "time"
|
||||
)
|
||||
|
||||
type testClient struct {
|
||||
@ -32,11 +31,9 @@ func (c *testClient) Call(ctx context.Context, req *proto.CallReq, opts ...clien
|
||||
)
|
||||
opts = append(opts,
|
||||
v3.Method(http.MethodPost),
|
||||
v3.Path("/v1/call"),
|
||||
v3.Path("/Call"),
|
||||
v3.Body("*"),
|
||||
)
|
||||
td := time.Duration(5000000000)
|
||||
opts = append(opts, client.WithRequestTimeout(td))
|
||||
rsp := &proto.CallRsp{}
|
||||
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
|
||||
if err != nil {
|
||||
@ -50,10 +47,6 @@ type testServer struct {
|
||||
}
|
||||
|
||||
func (h *testServer) Call(ctx context.Context, req *proto.CallReq, rsp *proto.CallRsp) error {
|
||||
var cancel context.CancelFunc
|
||||
td := time.Duration(5000000000)
|
||||
ctx, cancel = context.WithTimeout(ctx, td)
|
||||
defer cancel()
|
||||
return h.TestServer.Call(ctx, req, rsp)
|
||||
}
|
||||
|
@ -1,102 +0,0 @@
|
||||
// Code generated by protoc-gen-go-drpc. DO NOT EDIT.
|
||||
// protoc-gen-go-drpc version: v0.0.32
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
errors "errors"
|
||||
proto "google.golang.org/protobuf/proto"
|
||||
drpc "storj.io/drpc"
|
||||
drpcerr "storj.io/drpc/drpcerr"
|
||||
)
|
||||
|
||||
type drpcEncoding_File_test_proto struct{}
|
||||
|
||||
func (drpcEncoding_File_test_proto) Marshal(msg drpc.Message) ([]byte, error) {
|
||||
return proto.Marshal(msg.(proto.Message))
|
||||
}
|
||||
|
||||
func (drpcEncoding_File_test_proto) MarshalAppend(buf []byte, msg drpc.Message) ([]byte, error) {
|
||||
return proto.MarshalOptions{}.MarshalAppend(buf, msg.(proto.Message))
|
||||
}
|
||||
|
||||
func (drpcEncoding_File_test_proto) Unmarshal(buf []byte, msg drpc.Message) error {
|
||||
return proto.Unmarshal(buf, msg.(proto.Message))
|
||||
}
|
||||
|
||||
type DRPCTestClient interface {
|
||||
DRPCConn() drpc.Conn
|
||||
|
||||
Call(ctx context.Context, in *CallReq) (*CallRsp, error)
|
||||
}
|
||||
|
||||
type drpcTestClient struct {
|
||||
cc drpc.Conn
|
||||
}
|
||||
|
||||
func NewDRPCTestClient(cc drpc.Conn) DRPCTestClient {
|
||||
return &drpcTestClient{cc}
|
||||
}
|
||||
|
||||
func (c *drpcTestClient) DRPCConn() drpc.Conn { return c.cc }
|
||||
|
||||
func (c *drpcTestClient) Call(ctx context.Context, in *CallReq) (*CallRsp, error) {
|
||||
out := new(CallRsp)
|
||||
err := c.cc.Invoke(ctx, "/test.v1.Test/Call", drpcEncoding_File_test_proto{}, in, out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
type DRPCTestServer interface {
|
||||
Call(context.Context, *CallReq) (*CallRsp, error)
|
||||
}
|
||||
|
||||
type DRPCTestUnimplementedServer struct{}
|
||||
|
||||
func (s *DRPCTestUnimplementedServer) Call(context.Context, *CallReq) (*CallRsp, error) {
|
||||
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||
}
|
||||
|
||||
type DRPCTestDescription struct{}
|
||||
|
||||
func (DRPCTestDescription) NumMethods() int { return 1 }
|
||||
|
||||
func (DRPCTestDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
|
||||
switch n {
|
||||
case 0:
|
||||
return "/test.v1.Test/Call", drpcEncoding_File_test_proto{},
|
||||
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||
return srv.(DRPCTestServer).
|
||||
Call(
|
||||
ctx,
|
||||
in1.(*CallReq),
|
||||
)
|
||||
}, DRPCTestServer.Call, true
|
||||
default:
|
||||
return "", nil, nil, nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func DRPCRegisterTest(mux drpc.Mux, impl DRPCTestServer) error {
|
||||
return mux.Register(impl, DRPCTestDescription{})
|
||||
}
|
||||
|
||||
type DRPCTest_CallStream interface {
|
||||
drpc.Stream
|
||||
SendAndClose(*CallRsp) error
|
||||
}
|
||||
|
||||
type drpcTest_CallStream struct {
|
||||
drpc.Stream
|
||||
}
|
||||
|
||||
func (x *drpcTest_CallStream) SendAndClose(m *CallRsp) error {
|
||||
if err := x.MsgSend(m, drpcEncoding_File_test_proto{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return x.CloseSend()
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.21.12
|
||||
// source: test.proto
|
||||
// source: ngpb.proto
|
||||
|
||||
package pb
|
||||
|
||||
@ -35,7 +35,7 @@ type CallReq struct {
|
||||
func (x *CallReq) Reset() {
|
||||
*x = CallReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[0]
|
||||
mi := &file_ngpb_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -48,7 +48,7 @@ func (x *CallReq) String() string {
|
||||
func (*CallReq) ProtoMessage() {}
|
||||
|
||||
func (x *CallReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_proto_msgTypes[0]
|
||||
mi := &file_ngpb_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -61,7 +61,7 @@ func (x *CallReq) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use CallReq.ProtoReflect.Descriptor instead.
|
||||
func (*CallReq) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{0}
|
||||
return file_ngpb_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *CallReq) GetReq() string {
|
||||
@ -82,7 +82,7 @@ type CallRsp struct {
|
||||
func (x *CallRsp) Reset() {
|
||||
*x = CallRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[1]
|
||||
mi := &file_ngpb_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -95,7 +95,7 @@ func (x *CallRsp) String() string {
|
||||
func (*CallRsp) ProtoMessage() {}
|
||||
|
||||
func (x *CallRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_proto_msgTypes[1]
|
||||
mi := &file_ngpb_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -108,7 +108,7 @@ func (x *CallRsp) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use CallRsp.ProtoReflect.Descriptor instead.
|
||||
func (*CallRsp) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{1}
|
||||
return file_ngpb_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *CallRsp) GetRsp() string {
|
||||
@ -129,7 +129,7 @@ type Error struct {
|
||||
func (x *Error) Reset() {
|
||||
*x = Error{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[2]
|
||||
mi := &file_ngpb_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -142,7 +142,7 @@ func (x *Error) String() string {
|
||||
func (*Error) ProtoMessage() {}
|
||||
|
||||
func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_proto_msgTypes[2]
|
||||
mi := &file_ngpb_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -155,7 +155,7 @@ func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Error.ProtoReflect.Descriptor instead.
|
||||
func (*Error) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{2}
|
||||
return file_ngpb_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Error) GetErr() string {
|
||||
@ -165,56 +165,57 @@ func (x *Error) GetErr() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_test_proto protoreflect.FileDescriptor
|
||||
var File_ngpb_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_test_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x74, 0x65,
|
||||
0x73, 0x74, 0x2e, 0x76, 0x31, 0x1a, 0x0d, 0x74, 0x61, 0x67, 0x2f, 0x74, 0x61, 0x67, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x6f, 0x70, 0x65,
|
||||
0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65,
|
||||
0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 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, 0x72, 0x0a,
|
||||
0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x6a, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x10, 0x2e,
|
||||
0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a,
|
||||
0x10, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73,
|
||||
0x70, 0x22, 0x3e, 0xaa, 0x84, 0x9e, 0x03, 0x1c, 0x2a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x42, 0x14,
|
||||
0x0a, 0x12, 0x12, 0x10, 0x0a, 0x0e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0d, 0x22, 0x08, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x63, 0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0xba, 0xea, 0xff, 0xf9, 0x01, 0x04, 0x0a, 0x02, 0x35,
|
||||
0x73, 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 file_ngpb_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x6e, 0x67, 0x70, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x74, 0x65,
|
||||
0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x6e, 0x67, 0x70, 0x62, 0x1a, 0x0d, 0x74, 0x61, 0x67, 0x2f,
|
||||
0x74, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x61,
|
||||
0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x1a, 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f,
|
||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67,
|
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77,
|
||||
0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 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, 0x7c, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x74, 0x0a, 0x04, 0x43, 0x61,
|
||||
0x6c, 0x6c, 0x12, 0x15, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x6e, 0x67, 0x70,
|
||||
0x62, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x74, 0x65, 0x73, 0x74,
|
||||
0x2e, 0x76, 0x31, 0x2e, 0x6e, 0x67, 0x70, 0x62, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73, 0x70,
|
||||
0x22, 0x3e, 0xaa, 0x84, 0x9e, 0x03, 0x1c, 0x2a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x42, 0x14, 0x0a,
|
||||
0x12, 0x12, 0x10, 0x0a, 0x0e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72,
|
||||
0x72, 0x6f, 0x72, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0d, 0x22, 0x08, 0x2f, 0x76, 0x31, 0x2f, 0x63,
|
||||
0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0xba, 0xea, 0xff, 0xf9, 0x01, 0x04, 0x0a, 0x02, 0x35, 0x73,
|
||||
0x42, 0x32, 0x5a, 0x30, 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, 0x6e, 0x67, 0x70,
|
||||
0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_test_proto_rawDescOnce sync.Once
|
||||
file_test_proto_rawDescData = file_test_proto_rawDesc
|
||||
file_ngpb_proto_rawDescOnce sync.Once
|
||||
file_ngpb_proto_rawDescData = file_ngpb_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_test_proto_rawDescGZIP() []byte {
|
||||
file_test_proto_rawDescOnce.Do(func() {
|
||||
file_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_proto_rawDescData)
|
||||
func file_ngpb_proto_rawDescGZIP() []byte {
|
||||
file_ngpb_proto_rawDescOnce.Do(func() {
|
||||
file_ngpb_proto_rawDescData = protoimpl.X.CompressGZIP(file_ngpb_proto_rawDescData)
|
||||
})
|
||||
return file_test_proto_rawDescData
|
||||
return file_ngpb_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_test_proto_goTypes = []interface{}{
|
||||
(*CallReq)(nil), // 0: test.v1.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.CallRsp
|
||||
(*Error)(nil), // 2: test.v1.Error
|
||||
var file_ngpb_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_ngpb_proto_goTypes = []interface{}{
|
||||
(*CallReq)(nil), // 0: test.v1.ngpb.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.ngpb.CallRsp
|
||||
(*Error)(nil), // 2: test.v1.ngpb.Error
|
||||
}
|
||||
var file_test_proto_depIdxs = []int32{
|
||||
0, // 0: test.v1.Test.Call:input_type -> test.v1.CallReq
|
||||
1, // 1: test.v1.Test.Call:output_type -> test.v1.CallRsp
|
||||
var file_ngpb_proto_depIdxs = []int32{
|
||||
0, // 0: test.v1.ngpb.Test.Call:input_type -> test.v1.ngpb.CallReq
|
||||
1, // 1: test.v1.ngpb.Test.Call:output_type -> test.v1.ngpb.CallRsp
|
||||
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
|
||||
@ -222,13 +223,13 @@ var file_test_proto_depIdxs = []int32{
|
||||
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 {
|
||||
func init() { file_ngpb_proto_init() }
|
||||
func file_ngpb_proto_init() {
|
||||
if File_ngpb_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_ngpb_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CallReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -240,7 +241,7 @@ func file_test_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_ngpb_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CallRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -252,7 +253,7 @@ func file_test_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_ngpb_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Error); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -269,18 +270,18 @@ func file_test_proto_init() {
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_test_proto_rawDesc,
|
||||
RawDescriptor: file_ngpb_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_test_proto_goTypes,
|
||||
DependencyIndexes: file_test_proto_depIdxs,
|
||||
MessageInfos: file_test_proto_msgTypes,
|
||||
GoTypes: file_ngpb_proto_goTypes,
|
||||
DependencyIndexes: file_ngpb_proto_depIdxs,
|
||||
MessageInfos: file_ngpb_proto_msgTypes,
|
||||
}.Build()
|
||||
File_test_proto = out.File
|
||||
file_test_proto_rawDesc = nil
|
||||
file_test_proto_goTypes = nil
|
||||
file_test_proto_depIdxs = nil
|
||||
File_ngpb_proto = out.File
|
||||
file_ngpb_proto_rawDesc = nil
|
||||
file_ngpb_proto_goTypes = nil
|
||||
file_ngpb_proto_depIdxs = nil
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package test.v1;
|
||||
package test.v1.ngpb;
|
||||
|
||||
option go_package = "go.unistack.org/micro-tests/server/combo/proto;pb";
|
||||
option go_package = "go.unistack.org/micro-tests/server/combo/ngpb;pb";
|
||||
|
||||
import "tag/tag.proto";
|
||||
import "api/annotations.proto";
|
@ -2,7 +2,7 @@
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.21.12
|
||||
// source: test.proto
|
||||
// source: ngpb.proto
|
||||
|
||||
package pb
|
||||
|
||||
@ -36,7 +36,7 @@ func NewTestClient(cc grpc.ClientConnInterface) TestClient {
|
||||
|
||||
func (c *testClient) Call(ctx context.Context, in *CallReq, opts ...grpc.CallOption) (*CallRsp, error) {
|
||||
out := new(CallRsp)
|
||||
err := c.cc.Invoke(ctx, "/test.v1.Test/Call", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/test.v1.ngpb.Test/Call", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -82,7 +82,7 @@ func _Test_Call_Handler(srv interface{}, ctx context.Context, dec func(interface
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/test.v1.Test/Call",
|
||||
FullMethod: "/test.v1.ngpb.Test/Call",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TestServer).Call(ctx, req.(*CallReq))
|
||||
@ -94,7 +94,7 @@ func _Test_Call_Handler(srv interface{}, ctx context.Context, dec func(interface
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Test_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "test.v1.Test",
|
||||
ServiceName: "test.v1.ngpb.Test",
|
||||
HandlerType: (*TestServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
@ -103,5 +103,5 @@ var Test_ServiceDesc = grpc.ServiceDesc{
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "test.proto",
|
||||
Metadata: "ngpb.proto",
|
||||
}
|
50
server/combo/proto/apidocs.swagger.yaml
Normal file
50
server/combo/proto/apidocs.swagger.yaml
Normal file
@ -0,0 +1,50 @@
|
||||
# Generated with protoc-gen-go-micro
|
||||
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Test API
|
||||
version: 0.0.1
|
||||
paths:
|
||||
/Call:
|
||||
post:
|
||||
tags:
|
||||
- Test
|
||||
operationId: Call
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CallReq'
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: Default
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CallRsp'
|
||||
components:
|
||||
schemas:
|
||||
CallReq:
|
||||
type: object
|
||||
properties:
|
||||
req:
|
||||
type: string
|
||||
CallRsp:
|
||||
type: object
|
||||
properties:
|
||||
rsp:
|
||||
type: string
|
||||
Error:
|
||||
type: object
|
||||
properties:
|
||||
err:
|
||||
type: string
|
||||
tags:
|
||||
- name: Test
|
@ -2,7 +2,7 @@
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.21.12
|
||||
// source: test.proto
|
||||
// source: proto.proto
|
||||
|
||||
package pb
|
||||
|
||||
@ -35,7 +35,7 @@ type CallReq struct {
|
||||
func (x *CallReq) Reset() {
|
||||
*x = CallReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[0]
|
||||
mi := &file_proto_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -48,7 +48,7 @@ func (x *CallReq) String() string {
|
||||
func (*CallReq) ProtoMessage() {}
|
||||
|
||||
func (x *CallReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_proto_msgTypes[0]
|
||||
mi := &file_proto_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -61,7 +61,7 @@ func (x *CallReq) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use CallReq.ProtoReflect.Descriptor instead.
|
||||
func (*CallReq) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{0}
|
||||
return file_proto_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *CallReq) GetReq() string {
|
||||
@ -82,7 +82,7 @@ type CallRsp struct {
|
||||
func (x *CallRsp) Reset() {
|
||||
*x = CallRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[1]
|
||||
mi := &file_proto_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -95,7 +95,7 @@ func (x *CallRsp) String() string {
|
||||
func (*CallRsp) ProtoMessage() {}
|
||||
|
||||
func (x *CallRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_proto_msgTypes[1]
|
||||
mi := &file_proto_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -108,7 +108,7 @@ func (x *CallRsp) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use CallRsp.ProtoReflect.Descriptor instead.
|
||||
func (*CallRsp) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{1}
|
||||
return file_proto_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *CallRsp) GetRsp() string {
|
||||
@ -129,7 +129,7 @@ type Error struct {
|
||||
func (x *Error) Reset() {
|
||||
*x = Error{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[2]
|
||||
mi := &file_proto_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -142,7 +142,7 @@ func (x *Error) String() string {
|
||||
func (*Error) ProtoMessage() {}
|
||||
|
||||
func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_proto_msgTypes[2]
|
||||
mi := &file_proto_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -155,7 +155,7 @@ func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Error.ProtoReflect.Descriptor instead.
|
||||
func (*Error) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{2}
|
||||
return file_proto_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Error) GetErr() string {
|
||||
@ -165,56 +165,57 @@ func (x *Error) GetErr() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_test_proto protoreflect.FileDescriptor
|
||||
var File_proto_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_test_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x74, 0x65,
|
||||
0x73, 0x74, 0x2e, 0x76, 0x31, 0x1a, 0x0d, 0x74, 0x61, 0x67, 0x2f, 0x74, 0x61, 0x67, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x6f, 0x70, 0x65,
|
||||
0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65,
|
||||
0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 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, 0x72, 0x0a,
|
||||
0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x6a, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x10, 0x2e,
|
||||
0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a,
|
||||
0x10, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73,
|
||||
0x70, 0x22, 0x3e, 0xaa, 0x84, 0x9e, 0x03, 0x1c, 0x2a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x42, 0x14,
|
||||
0x0a, 0x12, 0x12, 0x10, 0x0a, 0x0e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0d, 0x22, 0x08, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x63, 0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0xba, 0xea, 0xff, 0xf9, 0x01, 0x04, 0x0a, 0x02, 0x35,
|
||||
0x73, 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 file_proto_proto_rawDesc = []byte{
|
||||
0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x74,
|
||||
0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x74, 0x61,
|
||||
0x67, 0x2f, 0x74, 0x61, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x61, 0x70, 0x69,
|
||||
0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x1a, 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e,
|
||||
0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
|
||||
0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
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,
|
||||
}
|
||||
|
||||
var (
|
||||
file_test_proto_rawDescOnce sync.Once
|
||||
file_test_proto_rawDescData = file_test_proto_rawDesc
|
||||
file_proto_proto_rawDescOnce sync.Once
|
||||
file_proto_proto_rawDescData = file_proto_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_test_proto_rawDescGZIP() []byte {
|
||||
file_test_proto_rawDescOnce.Do(func() {
|
||||
file_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_proto_rawDescData)
|
||||
func file_proto_proto_rawDescGZIP() []byte {
|
||||
file_proto_proto_rawDescOnce.Do(func() {
|
||||
file_proto_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_proto_rawDescData)
|
||||
})
|
||||
return file_test_proto_rawDescData
|
||||
return file_proto_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_test_proto_goTypes = []interface{}{
|
||||
(*CallReq)(nil), // 0: test.v1.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.CallRsp
|
||||
(*Error)(nil), // 2: test.v1.Error
|
||||
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
|
||||
}
|
||||
var file_test_proto_depIdxs = []int32{
|
||||
0, // 0: test.v1.Test.Call:input_type -> test.v1.CallReq
|
||||
1, // 1: test.v1.Test.Call:output_type -> test.v1.CallRsp
|
||||
var file_proto_proto_depIdxs = []int32{
|
||||
0, // 0: test.v1.proto.Test.Call:input_type -> test.v1.proto.CallReq
|
||||
1, // 1: test.v1.proto.Test.Call:output_type -> test.v1.proto.CallRsp
|
||||
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
|
||||
@ -222,13 +223,13 @@ var file_test_proto_depIdxs = []int32{
|
||||
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 {
|
||||
func init() { file_proto_proto_init() }
|
||||
func file_proto_proto_init() {
|
||||
if File_proto_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proto_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CallReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -240,7 +241,7 @@ func file_test_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proto_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CallRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -252,7 +253,7 @@ func file_test_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_proto_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Error); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -269,18 +270,18 @@ func file_test_proto_init() {
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_test_proto_rawDesc,
|
||||
RawDescriptor: file_proto_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_test_proto_goTypes,
|
||||
DependencyIndexes: file_test_proto_depIdxs,
|
||||
MessageInfos: file_test_proto_msgTypes,
|
||||
GoTypes: file_proto_proto_goTypes,
|
||||
DependencyIndexes: file_proto_proto_depIdxs,
|
||||
MessageInfos: file_proto_proto_msgTypes,
|
||||
}.Build()
|
||||
File_test_proto = out.File
|
||||
file_test_proto_rawDesc = nil
|
||||
file_test_proto_goTypes = nil
|
||||
file_test_proto_depIdxs = nil
|
||||
File_proto_proto = out.File
|
||||
file_proto_proto_rawDesc = nil
|
||||
file_proto_proto_goTypes = nil
|
||||
file_proto_proto_depIdxs = nil
|
||||
}
|
38
server/combo/proto/proto.proto
Normal file
38
server/combo/proto/proto.proto
Normal file
@ -0,0 +1,38 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package test.v1.proto;
|
||||
|
||||
option go_package = "go.unistack.org/micro-tests/server/combo/proto;pb";
|
||||
|
||||
import "tag/tag.proto";
|
||||
import "api/annotations.proto";
|
||||
import "openapiv3/annotations.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
service Test {
|
||||
rpc Call(CallReq) returns (CallRsp) {
|
||||
option (micro.openapiv3.openapiv3_operation) = {
|
||||
operation_id: "Call";
|
||||
responses: {
|
||||
default: {
|
||||
reference: {
|
||||
_ref: ".test.v1.proto.Error";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
option (micro.api.http) = { post: "/Call"; body: "*"; };
|
||||
};
|
||||
};
|
||||
|
||||
message CallReq {
|
||||
string req = 1;
|
||||
};
|
||||
|
||||
message CallRsp {
|
||||
string rsp = 1;
|
||||
};
|
||||
|
||||
message Error {
|
||||
string err = 1;
|
||||
};
|
@ -1,286 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.21.12
|
||||
// source: test.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
_ "go.unistack.org/micro-proto/v3/api"
|
||||
_ "go.unistack.org/micro-proto/v3/openapiv3"
|
||||
_ "go.unistack.org/micro-proto/v3/tag"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
_ "google.golang.org/protobuf/types/known/wrapperspb"
|
||||
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)
|
||||
)
|
||||
|
||||
type CallReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Req string `protobuf:"bytes,1,opt,name=req,proto3" json:"req,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CallReq) Reset() {
|
||||
*x = CallReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CallReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CallReq) ProtoMessage() {}
|
||||
|
||||
func (x *CallReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_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 CallReq.ProtoReflect.Descriptor instead.
|
||||
func (*CallReq) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *CallReq) GetReq() string {
|
||||
if x != nil {
|
||||
return x.Req
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CallRsp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Rsp string `protobuf:"bytes,1,opt,name=rsp,proto3" json:"rsp,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CallRsp) Reset() {
|
||||
*x = CallRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CallRsp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CallRsp) ProtoMessage() {}
|
||||
|
||||
func (x *CallRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_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 CallRsp.ProtoReflect.Descriptor instead.
|
||||
func (*CallRsp) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *CallRsp) GetRsp() string {
|
||||
if x != nil {
|
||||
return x.Rsp
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Err string `protobuf:"bytes,1,opt,name=err,proto3" json:"err,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Error) Reset() {
|
||||
*x = Error{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_test_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Error) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Error) ProtoMessage() {}
|
||||
|
||||
func (x *Error) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_test_proto_msgTypes[2]
|
||||
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 Error.ProtoReflect.Descriptor instead.
|
||||
func (*Error) Descriptor() ([]byte, []int) {
|
||||
return file_test_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Error) GetErr() string {
|
||||
if x != nil {
|
||||
return x.Err
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
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, 0x07, 0x74, 0x65,
|
||||
0x73, 0x74, 0x2e, 0x76, 0x31, 0x1a, 0x0d, 0x74, 0x61, 0x67, 0x2f, 0x74, 0x61, 0x67, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x6f, 0x70, 0x65,
|
||||
0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65,
|
||||
0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 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, 0x72, 0x0a,
|
||||
0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x6a, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x10, 0x2e,
|
||||
0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x1a,
|
||||
0x10, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x52, 0x73,
|
||||
0x70, 0x22, 0x3e, 0xaa, 0x84, 0x9e, 0x03, 0x1c, 0x2a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x42, 0x14,
|
||||
0x0a, 0x12, 0x12, 0x10, 0x0a, 0x0e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0xb2, 0xea, 0xff, 0xf9, 0x01, 0x0d, 0x22, 0x08, 0x2f, 0x76, 0x31, 0x2f,
|
||||
0x63, 0x61, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0xba, 0xea, 0xff, 0xf9, 0x01, 0x04, 0x0a, 0x02, 0x35,
|
||||
0x73, 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 (
|
||||
file_test_proto_rawDescOnce sync.Once
|
||||
file_test_proto_rawDescData = file_test_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_test_proto_rawDescGZIP() []byte {
|
||||
file_test_proto_rawDescOnce.Do(func() {
|
||||
file_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_proto_rawDescData)
|
||||
})
|
||||
return file_test_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_test_proto_goTypes = []interface{}{
|
||||
(*CallReq)(nil), // 0: test.v1.CallReq
|
||||
(*CallRsp)(nil), // 1: test.v1.CallRsp
|
||||
(*Error)(nil), // 2: test.v1.Error
|
||||
}
|
||||
var file_test_proto_depIdxs = []int32{
|
||||
0, // 0: test.v1.Test.Call:input_type -> test.v1.CallReq
|
||||
1, // 1: test.v1.Test.Call:output_type -> test.v1.CallRsp
|
||||
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
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CallReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CallRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Error); 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_test_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_test_proto_goTypes,
|
||||
DependencyIndexes: file_test_proto_depIdxs,
|
||||
MessageInfos: file_test_proto_msgTypes,
|
||||
}.Build()
|
||||
File_test_proto = out.File
|
||||
file_test_proto_rawDesc = nil
|
||||
file_test_proto_goTypes = nil
|
||||
file_test_proto_depIdxs = nil
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user