Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-11 02:00:29 +03:00
parent e7e1ff15f4
commit 1aa324c17f
63 changed files with 2488 additions and 1165 deletions

View File

@@ -1,19 +1,31 @@
// 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: test.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"
client "go.unistack.org/micro/v3/client"
server "go.unistack.org/micro/v3/server"
http "net/http"
time "time"
)
var (
TestDoubleServerEndpoints = []v3.EndpointMetadata{
{
Name: "TestDouble.CallDouble",
Path: "/v1/testdouble/call/name/{name}",
Method: "POST",
Body: "*",
Stream: false,
},
}
)
type testDoubleClient struct {
c client.Client
name string
@@ -27,12 +39,12 @@ func (c *testDoubleClient) CallDouble(ctx context.Context, req *CallReq, opts ..
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
v31.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/testdouble/call/name/{name}"),
v3.Body("*"),
v31.Method(http.MethodPost),
v31.Path("/v1/testdouble/call/name/{name}"),
v31.Body("*"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
@@ -65,10 +77,43 @@ func RegisterTestDoubleServer(s server.Server, sh TestDoubleServer, opts ...serv
}
h := &testDoubleServer{sh}
var nopts []server.HandlerOption
nopts = append(nopts, v31.HandlerEndpoints(TestDoubleServerEndpoints))
nopts = append(nopts, v3.HandlerEndpoints(TestDoubleServerEndpoints))
return s.Handle(s.NewHandler(&TestDouble{h}, append(nopts, opts...)...))
}
var (
TestServerEndpoints = []v3.EndpointMetadata{
{
Name: "Test.CallRepeatedString",
Path: "/v1/test/call_repeated_string",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "Test.CallRepeatedInt64",
Path: "/v1/test/call_repeated_int64",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "Test.Call",
Path: "/v1/test/call/{name}",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "Test.CallError",
Path: "/v1/test/callerror/{name}",
Method: "POST",
Body: "*",
Stream: false,
},
}
)
type testClient struct {
c client.Client
name string
@@ -82,12 +127,12 @@ func (c *testClient) CallRepeatedString(ctx context.Context, req *CallReq, opts
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
v31.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/test/call_repeated_string"),
v3.Body("*"),
v31.Method(http.MethodPost),
v31.Path("/v1/test/call_repeated_string"),
v31.Body("*"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
@@ -103,12 +148,12 @@ func (c *testClient) CallRepeatedInt64(ctx context.Context, req *CallReq, opts .
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
v31.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/test/call_repeated_int64"),
v3.Body("*"),
v31.Method(http.MethodPost),
v31.Path("/v1/test/call_repeated_int64"),
v31.Body("*"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
@@ -124,16 +169,16 @@ func (c *testClient) Call(ctx context.Context, req *CallReq, opts ...client.Call
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
v31.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/test/call/{name}"),
v3.Body("*"),
v31.Method(http.MethodPost),
v31.Path("/v1/test/call/{name}"),
v31.Body("*"),
)
opts = append(opts,
v3.Header("Clientid", "true"),
v3.Cookie("Csrftoken", "true"),
v31.Header("Clientid", "true"),
v31.Cookie("Csrftoken", "true"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
@@ -149,12 +194,12 @@ func (c *testClient) CallError(ctx context.Context, req *CallReq1, opts ...clien
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
v31.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/test/callerror/{name}"),
v3.Body("*"),
v31.Method(http.MethodPost),
v31.Path("/v1/test/callerror/{name}"),
v31.Body("*"),
)
rsp := &CallRsp1{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.CallError", req), rsp, opts...)
@@ -189,9 +234,9 @@ func (h *testServer) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
td := time.Duration(5000000000)
ctx, cancel = context.WithTimeout(ctx, td)
defer cancel()
v31.FillRequest(ctx, req,
v31.Header("Clientid", "true"),
v31.Cookie("Csrftoken", "true"),
v3.FillRequest(ctx, req,
v3.Header("Clientid", "true"),
v3.Cookie("Csrftoken", "true"),
)
return h.TestServer.Call(ctx, req, rsp)
}
@@ -212,6 +257,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...)...))
}