68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
|
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
|
||
|
// protoc-gen-go-micro version: v3.4.0
|
||
|
// source: test.proto
|
||
|
|
||
|
package pb
|
||
|
|
||
|
import (
|
||
|
context "context"
|
||
|
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) Call(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
|
||
|
rsp := &CallRsp{}
|
||
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "TestService.Call", req), rsp, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return rsp, nil
|
||
|
}
|
||
|
|
||
|
func (c *testServiceClient) Hello(ctx context.Context, req *CallReq, opts ...client.CallOption) (*CallRsp, error) {
|
||
|
rsp := &CallRsp{}
|
||
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "TestService.Hello", req), rsp, opts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return rsp, nil
|
||
|
}
|
||
|
|
||
|
type testServiceServer struct {
|
||
|
TestServiceServer
|
||
|
}
|
||
|
|
||
|
func (h *testServiceServer) Call(ctx context.Context, req *CallReq, rsp *CallRsp) error {
|
||
|
return h.TestServiceServer.Call(ctx, req, rsp)
|
||
|
}
|
||
|
|
||
|
func (h *testServiceServer) Hello(ctx context.Context, req *CallReq, rsp *CallRsp) error {
|
||
|
return h.TestServiceServer.Hello(ctx, req, rsp)
|
||
|
}
|
||
|
|
||
|
func RegisterTestServiceServer(s server.Server, sh TestServiceServer, opts ...server.HandlerOption) error {
|
||
|
type testService interface {
|
||
|
Call(ctx context.Context, req *CallReq, rsp *CallRsp) error
|
||
|
Hello(ctx context.Context, req *CallReq, rsp *CallRsp) 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...)...))
|
||
|
}
|