2021-06-30 17:53:06 +03:00
|
|
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
2021-10-27 01:24:35 +03:00
|
|
|
// protoc-gen-go-micro version: v3.5.3
|
2021-02-06 19:08:01 +03:00
|
|
|
// source: test.proto
|
2021-06-30 17:53:06 +03:00
|
|
|
|
2021-02-06 19:08:01 +03:00
|
|
|
package pb
|
|
|
|
|
|
|
|
import (
|
2021-02-27 13:51:39 +03:00
|
|
|
context "context"
|
2022-01-24 22:44:26 +03:00
|
|
|
http "net/http"
|
|
|
|
time "time"
|
|
|
|
|
2021-10-27 01:24:35 +03:00
|
|
|
v3 "go.unistack.org/micro-client-http/v3"
|
2021-10-27 13:17:06 +03:00
|
|
|
v31 "go.unistack.org/micro-server-http/v3"
|
2021-10-27 01:24:35 +03:00
|
|
|
api "go.unistack.org/micro/v3/api"
|
|
|
|
client "go.unistack.org/micro/v3/client"
|
|
|
|
server "go.unistack.org/micro/v3/server"
|
2021-02-06 19:08:01 +03:00
|
|
|
)
|
|
|
|
|
2021-03-09 14:25:27 +03:00
|
|
|
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) {
|
2021-03-22 00:10:15 +03:00
|
|
|
opts = append(opts,
|
2021-04-19 02:16:00 +03:00
|
|
|
v3.Method(http.MethodPost),
|
2021-07-31 15:17:18 +03:00
|
|
|
v3.Path("/v1/testdouble/call/name/{name}"),
|
2021-03-09 14:25:27 +03:00
|
|
|
v3.Body("*"),
|
|
|
|
)
|
2021-05-08 12:45:08 +03:00
|
|
|
opts = append(opts, client.WithRequestTimeout(time.Second*5))
|
2021-03-09 14:25:27 +03:00
|
|
|
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 {
|
2021-05-08 12:45:08 +03:00
|
|
|
var cancel context.CancelFunc
|
|
|
|
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
|
|
|
|
defer cancel()
|
2021-03-09 14:25:27 +03:00
|
|
|
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}
|
2021-04-19 02:16:00 +03:00
|
|
|
var nopts []server.HandlerOption
|
2021-06-30 17:53:06 +03:00
|
|
|
for _, endpoint := range TestDoubleEndpoints {
|
|
|
|
nopts = append(nopts, api.WithEndpoint(&endpoint))
|
2021-03-09 14:25:27 +03:00
|
|
|
}
|
2021-04-19 02:16:00 +03:00
|
|
|
return s.Handle(s.NewHandler(&TestDouble{h}, append(nopts, opts...)...))
|
2021-03-09 14:25:27 +03:00
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
type testClient struct {
|
|
|
|
c client.Client
|
2021-02-06 19:08:01 +03:00
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func NewTestClient(name string, c client.Client) TestClient {
|
|
|
|
return &testClient{c: c, name: name}
|
2021-02-06 19:08:01 +03:00
|
|
|
}
|
|
|
|
|
2021-04-19 11:36:58 +03:00
|
|
|
func (c *testClient) CallRepeatedString(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
|
2021-04-19 02:16:00 +03:00
|
|
|
opts = append(opts,
|
|
|
|
v3.Method(http.MethodPost),
|
2021-09-30 03:10:20 +03:00
|
|
|
v3.Path("/v1/test/call_repeated_string"),
|
2021-04-19 02:16:00 +03:00
|
|
|
v3.Body("*"),
|
|
|
|
)
|
2021-05-08 12:45:08 +03:00
|
|
|
opts = append(opts, client.WithRequestTimeout(time.Second*5))
|
2021-04-19 02:16:00 +03:00
|
|
|
rsp := &CallRsp{}
|
2021-04-19 11:36:58 +03:00
|
|
|
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) {
|
|
|
|
opts = append(opts,
|
|
|
|
v3.Method(http.MethodPost),
|
2021-09-30 03:10:20 +03:00
|
|
|
v3.Path("/v1/test/call_repeated_int64"),
|
2021-04-19 11:36:58 +03:00
|
|
|
v3.Body("*"),
|
|
|
|
)
|
2021-05-08 12:45:08 +03:00
|
|
|
opts = append(opts, client.WithRequestTimeout(time.Second*5))
|
2021-04-19 11:36:58 +03:00
|
|
|
rsp := &CallRsp{}
|
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.CallRepeatedInt64", req), rsp, opts...)
|
2021-04-19 02:16:00 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func (c *testClient) Call(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
|
2021-03-22 00:10:15 +03:00
|
|
|
opts = append(opts,
|
2021-04-19 02:16:00 +03:00
|
|
|
v3.Method(http.MethodPost),
|
2021-02-27 13:51:39 +03:00
|
|
|
v3.Path("/v1/test/call/{name}"),
|
|
|
|
v3.Body("*"),
|
2021-02-06 19:08:01 +03:00
|
|
|
)
|
2021-10-27 13:17:06 +03:00
|
|
|
opts = append(opts,
|
|
|
|
v3.Header("Clientid", "true"),
|
2021-12-29 02:05:30 +03:00
|
|
|
v3.Cookie("Csrftoken", "true"),
|
2021-10-27 13:17:06 +03:00
|
|
|
)
|
2021-05-08 12:45:08 +03:00
|
|
|
opts = append(opts, client.WithRequestTimeout(time.Second*5))
|
2021-02-06 19:08:01 +03:00
|
|
|
rsp := &CallRsp{}
|
2021-02-27 13:51:39 +03:00
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...)
|
2021-02-06 19:08:01 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func (c *testClient) CallError(ctx context.Context, req *CallReq1, opts ...client.CallOption) (*CallRsp1, error) {
|
2021-03-22 00:10:15 +03:00
|
|
|
opts = append(opts,
|
2021-04-19 02:16:00 +03:00
|
|
|
v3.Method(http.MethodPost),
|
2021-02-27 13:51:39 +03:00
|
|
|
v3.Path("/v1/test/callerror/{name}"),
|
|
|
|
v3.Body("*"),
|
2021-02-06 19:08:01 +03:00
|
|
|
)
|
|
|
|
rsp := &CallRsp1{}
|
2021-02-27 13:51:39 +03:00
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.CallError", req), rsp, opts...)
|
2021-02-06 19:08:01 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
type testServer struct {
|
|
|
|
TestServer
|
2021-02-06 19:08:01 +03:00
|
|
|
}
|
|
|
|
|
2021-04-19 11:36:58 +03:00
|
|
|
func (h *testServer) CallRepeatedString(ctx context.Context, req *CallReq, rsp *CallRsp) error {
|
2021-05-08 12:45:08 +03:00
|
|
|
var cancel context.CancelFunc
|
|
|
|
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
|
|
|
|
defer cancel()
|
2021-04-19 11:36:58 +03:00
|
|
|
return h.TestServer.CallRepeatedString(ctx, req, rsp)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *testServer) CallRepeatedInt64(ctx context.Context, req *CallReq, rsp *CallRsp) error {
|
2021-05-08 12:45:08 +03:00
|
|
|
var cancel context.CancelFunc
|
|
|
|
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
|
|
|
|
defer cancel()
|
2021-04-19 11:36:58 +03:00
|
|
|
return h.TestServer.CallRepeatedInt64(ctx, req, rsp)
|
2021-04-19 02:16:00 +03:00
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func (h *testServer) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error {
|
2021-05-08 12:45:08 +03:00
|
|
|
var cancel context.CancelFunc
|
|
|
|
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
|
|
|
|
defer cancel()
|
2021-10-27 13:17:06 +03:00
|
|
|
v31.FillRequest(ctx, req,
|
|
|
|
v31.Cookie("Csrftoken", "true"),
|
2022-01-13 01:18:21 +03:00
|
|
|
v31.Header("Clientid", "true"),
|
2021-10-27 13:17:06 +03:00
|
|
|
)
|
2021-02-27 13:51:39 +03:00
|
|
|
return h.TestServer.Call(ctx, req, rsp)
|
2021-02-06 19:08:01 +03:00
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func (h *testServer) CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) error {
|
|
|
|
return h.TestServer.CallError(ctx, req, rsp)
|
2021-02-06 19:08:01 +03:00
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error {
|
2021-02-06 19:08:01 +03:00
|
|
|
type test interface {
|
2021-04-19 11:36:58 +03:00
|
|
|
CallRepeatedString(ctx context.Context, req *CallReq, rsp *CallRsp) error
|
|
|
|
CallRepeatedInt64(ctx context.Context, req *CallReq, rsp *CallRsp) error
|
2021-02-27 13:51:39 +03:00
|
|
|
Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
|
|
|
|
CallError(ctx context.Context, req *CallReq1, rsp *CallRsp1) error
|
2021-02-06 19:08:01 +03:00
|
|
|
}
|
|
|
|
type Test struct {
|
|
|
|
test
|
|
|
|
}
|
2021-02-27 13:51:39 +03:00
|
|
|
h := &testServer{sh}
|
2021-04-19 02:16:00 +03:00
|
|
|
var nopts []server.HandlerOption
|
2021-06-30 17:53:06 +03:00
|
|
|
for _, endpoint := range TestEndpoints {
|
|
|
|
nopts = append(nopts, api.WithEndpoint(&endpoint))
|
2021-02-06 19:08:01 +03:00
|
|
|
}
|
2021-04-19 02:16:00 +03:00
|
|
|
return s.Handle(s.NewHandler(&Test{h}, append(nopts, opts...)...))
|
2021-02-06 19:08:01 +03:00
|
|
|
}
|