micro-tests/server/http/proto/test_micro_http.pb.go
Vasiliy Tolstov 1aa324c17f cleanup
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-12-11 02:00:29 +03:00

263 lines
6.9 KiB
Go

// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.10.4
// source: test.proto
package pb
import (
context "context"
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
}
func NewTestDoubleClient(name string, c client.Client) TestDoubleClient {
return &testDoubleClient{c: c, name: name}
}
func (c *testDoubleClient) CallDouble(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v31.ErrorMap(errmap),
)
opts = append(opts,
v31.Method(http.MethodPost),
v31.Path("/v1/testdouble/call/name/{name}"),
v31.Body("*"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
rsp := &CallRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "TestDouble.CallDouble", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
type testDoubleServer struct {
TestDoubleServer
}
func (h *testDoubleServer) CallDouble(ctx context.Context, req *CallReq, rsp *CallRsp) error {
var cancel context.CancelFunc
td := time.Duration(5000000000)
ctx, cancel = context.WithTimeout(ctx, td)
defer cancel()
return h.TestDoubleServer.CallDouble(ctx, req, rsp)
}
func RegisterTestDoubleServer(s server.Server, sh TestDoubleServer, opts ...server.HandlerOption) error {
type testDouble interface {
CallDouble(ctx context.Context, req *CallReq, rsp *CallRsp) error
}
type TestDouble struct {
testDouble
}
h := &testDoubleServer{sh}
var nopts []server.HandlerOption
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
}
func NewTestClient(name string, c client.Client) TestClient {
return &testClient{c: c, name: name}
}
func (c *testClient) CallRepeatedString(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v31.ErrorMap(errmap),
)
opts = append(opts,
v31.Method(http.MethodPost),
v31.Path("/v1/test/call_repeated_string"),
v31.Body("*"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
rsp := &CallRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.CallRepeatedString", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *testClient) CallRepeatedInt64(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v31.ErrorMap(errmap),
)
opts = append(opts,
v31.Method(http.MethodPost),
v31.Path("/v1/test/call_repeated_int64"),
v31.Body("*"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
rsp := &CallRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.CallRepeatedInt64", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *testClient) Call(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v31.ErrorMap(errmap),
)
opts = append(opts,
v31.Method(http.MethodPost),
v31.Path("/v1/test/call/{name}"),
v31.Body("*"),
)
opts = append(opts,
v31.Header("Clientid", "true"),
v31.Cookie("Csrftoken", "true"),
)
td := time.Duration(5000000000)
opts = append(opts, client.WithRequestTimeout(td))
rsp := &CallRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *testClient) CallError(ctx context.Context, req *CallReq1, opts ...client.CallOption) (*CallRsp1, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v31.ErrorMap(errmap),
)
opts = append(opts,
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...)
if err != nil {
return nil, err
}
return rsp, nil
}
type testServer struct {
TestServer
}
func (h *testServer) CallRepeatedString(ctx context.Context, req *CallReq, rsp *CallRsp) error {
var cancel context.CancelFunc
td := time.Duration(5000000000)
ctx, cancel = context.WithTimeout(ctx, td)
defer cancel()
return h.TestServer.CallRepeatedString(ctx, req, rsp)
}
func (h *testServer) CallRepeatedInt64(ctx context.Context, req *CallReq, rsp *CallRsp) error {
var cancel context.CancelFunc
td := time.Duration(5000000000)
ctx, cancel = context.WithTimeout(ctx, td)
defer cancel()
return h.TestServer.CallRepeatedInt64(ctx, req, rsp)
}
func (h *testServer) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error {
var cancel context.CancelFunc
td := time.Duration(5000000000)
ctx, cancel = context.WithTimeout(ctx, td)
defer cancel()
v3.FillRequest(ctx, req,
v3.Header("Clientid", "true"),
v3.Cookie("Csrftoken", "true"),
)
return h.TestServer.Call(ctx, req, rsp)
}
func (h *testServer) CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) error {
return h.TestServer.CallError(ctx, req, rsp)
}
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
type test interface {
CallRepeatedString(ctx context.Context, req *CallReq, rsp *CallRsp) error
CallRepeatedInt64(ctx context.Context, req *CallReq, rsp *CallRsp) error
Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) 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...)...))
}