71 lines
1.9 KiB
Go
71 lines
1.9 KiB
Go
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||
|
// protoc-gen-go-micro version: v3.4.1
|
||
|
// source: test.proto
|
||
|
|
||
|
package pb
|
||
|
|
||
|
import (
|
||
|
context "context"
|
||
|
http "net/http"
|
||
|
time "time"
|
||
|
|
||
|
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"
|
||
|
)
|
||
|
|
||
|
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/lookup/{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
|
||
|
}
|
||
|
|
||
|
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 RegisterTestServiceServer(s server.Server, sh TestServiceServer, opts ...server.HandlerOption) error {
|
||
|
type testService interface {
|
||
|
LookupUser(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) 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...)...))
|
||
|
}
|