git.colasdn.top/newrelic/go-agent@v3.26.0+incompatible/_integrations/nrmicro/example/proto/greeter.micro.go (about)

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