micro-tests/flow/proto/test_micro_http.pb.go
Vasiliy Tolstov 7bf66d519e update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-16 00:41:10 +03:00

153 lines
4.6 KiB
Go

// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.4.2
// source: test.proto
package pb
import (
context "context"
v3 "github.com/unistack-org/micro-client-http/v3"
api "github.com/unistack-org/micro/v3/api"
client "github.com/unistack-org/micro/v3/client"
server "github.com/unistack-org/micro/v3/server"
http "net/http"
time "time"
)
type testServiceClient struct {
c client.Client
name string
}
func NewTestServiceClient(name string, c client.Client) TestServiceClient {
return &testServiceClient{c: c, name: name}
}
func (c *testServiceClient) LookupUser(ctx context.Context, req *LookupUserReq, opts ...client.CallOption) (*LookupUserRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodGet),
v3.Path("/v1/user/{name}"),
)
opts = append(opts, client.WithRequestTimeout(time.Second*5))
rsp := &LookupUserRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "TestService.LookupUser", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *testServiceClient) UpdateUser(ctx context.Context, req *UpdateUserReq, opts ...client.CallOption) (*UpdateUserRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPut),
v3.Path("/v1/user/{name}"),
v3.Body("*"),
)
opts = append(opts, client.WithRequestTimeout(time.Second*5))
rsp := &UpdateUserRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "TestService.UpdateUser", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *testServiceClient) DeleteUser(ctx context.Context, req *DeleteUserReq, opts ...client.CallOption) (*DeleteUserRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodDelete),
v3.Path("/v1/user/{name}"),
)
opts = append(opts, client.WithRequestTimeout(time.Second*5))
rsp := &DeleteUserRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "TestService.DeleteUser", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
func (c *testServiceClient) MailUser(ctx context.Context, req *MailUserReq, opts ...client.CallOption) (*MailUserRsp, error) {
errmap := make(map[string]interface{}, 1)
errmap["default"] = &Error{}
opts = append(opts,
v3.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/user/{name}/mail"),
v3.Body("*"),
)
opts = append(opts, client.WithRequestTimeout(time.Second*5))
rsp := &MailUserRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "TestService.MailUser", req), rsp, opts...)
if err != nil {
return nil, err
}
return rsp, nil
}
type testServiceServer struct {
TestServiceServer
}
func (h *testServiceServer) LookupUser(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) error {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
defer cancel()
return h.TestServiceServer.LookupUser(ctx, req, rsp)
}
func (h *testServiceServer) UpdateUser(ctx context.Context, req *UpdateUserReq, rsp *UpdateUserRsp) error {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
defer cancel()
return h.TestServiceServer.UpdateUser(ctx, req, rsp)
}
func (h *testServiceServer) DeleteUser(ctx context.Context, req *DeleteUserReq, rsp *DeleteUserRsp) error {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
defer cancel()
return h.TestServiceServer.DeleteUser(ctx, req, rsp)
}
func (h *testServiceServer) MailUser(ctx context.Context, req *MailUserReq, rsp *MailUserRsp) error {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Second*5)
defer cancel()
return h.TestServiceServer.MailUser(ctx, req, rsp)
}
func RegisterTestServiceServer(s server.Server, sh TestServiceServer, opts ...server.HandlerOption) error {
type testService interface {
LookupUser(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) error
UpdateUser(ctx context.Context, req *UpdateUserReq, rsp *UpdateUserRsp) error
DeleteUser(ctx context.Context, req *DeleteUserReq, rsp *DeleteUserRsp) error
MailUser(ctx context.Context, req *MailUserReq, rsp *MailUserRsp) error
}
type TestService struct {
testService
}
h := &testServiceServer{sh}
var nopts []server.HandlerOption
for _, endpoint := range TestServiceEndpoints {
nopts = append(nopts, api.WithEndpoint(&endpoint))
}
return s.Handle(s.NewHandler(&TestService{h}, append(nopts, opts...)...))
}