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

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