gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/server/grpc/proto/test.micro.go (about)

     1  // Code generated by protoc-gen-micro. DO NOT EDIT.
     2  // source: go-micro/service/grpc/proto/test.proto
     3  
     4  package test
     5  
     6  import (
     7  	fmt "fmt"
     8  	proto "github.com/golang/protobuf/proto"
     9  	math "math"
    10  )
    11  
    12  import (
    13  	context "context"
    14  	client "gitee.com/liuxuezhan/go-micro-v1.18.0/client"
    15  	server "gitee.com/liuxuezhan/go-micro-v1.18.0/server"
    16  )
    17  
    18  // Reference imports to suppress errors if they are not otherwise used.
    19  var _ = proto.Marshal
    20  var _ = fmt.Errorf
    21  var _ = math.Inf
    22  
    23  // This is a compile-time assertion to ensure that this generated file
    24  // is compatible with the proto package it is being compiled against.
    25  // A compilation error at this line likely means your copy of the
    26  // proto package needs to be updated.
    27  const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
    28  
    29  // Reference imports to suppress errors if they are not otherwise used.
    30  var _ context.Context
    31  var _ client.Option
    32  var _ server.Option
    33  
    34  // Client API for Test service
    35  
    36  type TestService interface {
    37  	Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error)
    38  }
    39  
    40  type testService struct {
    41  	c    client.Client
    42  	name string
    43  }
    44  
    45  func NewTestService(name string, c client.Client) TestService {
    46  	if c == nil {
    47  		c = client.NewClient()
    48  	}
    49  	if len(name) == 0 {
    50  		name = "test"
    51  	}
    52  	return &testService{
    53  		c:    c,
    54  		name: name,
    55  	}
    56  }
    57  
    58  func (c *testService) Call(ctx context.Context, in *Request, opts ...client.CallOption) (*Response, error) {
    59  	req := c.c.NewRequest(c.name, "Test.Call", in)
    60  	out := new(Response)
    61  	err := c.c.Call(ctx, req, out, opts...)
    62  	if err != nil {
    63  		return nil, err
    64  	}
    65  	return out, nil
    66  }
    67  
    68  // Server API for Test service
    69  
    70  type TestHandler interface {
    71  	Call(context.Context, *Request, *Response) error
    72  }
    73  
    74  func RegisterTestHandler(s server.Server, hdlr TestHandler, opts ...server.HandlerOption) error {
    75  	type test interface {
    76  		Call(ctx context.Context, in *Request, out *Response) error
    77  	}
    78  	type Test struct {
    79  		test
    80  	}
    81  	h := &testHandler{hdlr}
    82  	return s.Handle(s.NewHandler(&Test{h}, opts...))
    83  }
    84  
    85  type testHandler struct {
    86  	TestHandler
    87  }
    88  
    89  func (h *testHandler) Call(ctx context.Context, in *Request, out *Response) error {
    90  	return h.TestHandler.Call(ctx, in, out)
    91  }