github.com/micro/go-micro/examples@v0.0.0-20210105173217-bf4ab679e18b/template/fnc/proto/example/example.micro.go (about)

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