github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/secure/srv/proto/hello/hello.micro.go (about)

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