优惠券rpc数据结构及方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
5.4 KiB

  1. // Code generated by protoc-gen-go.
  2. // source: coupon.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package couponrpc is a generated protocol buffer package.
  6. It is generated from these files:
  7. coupon.proto
  8. It has these top-level messages:
  9. CouponRequest
  10. CouponResponse
  11. */
  12. package couponrpc
  13. import proto "github.com/chai2010/protorpc/proto"
  14. import math "math"
  15. import "io"
  16. import "log"
  17. import "net"
  18. import "net/rpc"
  19. import "time"
  20. import protorpc "github.com/chai2010/protorpc"
  21. // Reference imports to suppress errors if they are not otherwise used.
  22. var _ = proto.Marshal
  23. var _ = math.Inf
  24. // 是否可用请求结构
  25. type CouponRequest struct {
  26. Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
  27. Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"`
  28. Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"`
  29. XXX_unrecognized []byte `json:"-"`
  30. }
  31. func (m *CouponRequest) Reset() { *m = CouponRequest{} }
  32. func (m *CouponRequest) String() string { return proto.CompactTextString(m) }
  33. func (*CouponRequest) ProtoMessage() {}
  34. func (m *CouponRequest) GetData() string {
  35. if m != nil && m.Data != nil {
  36. return *m.Data
  37. }
  38. return ""
  39. }
  40. func (m *CouponRequest) GetTime() string {
  41. if m != nil && m.Time != nil {
  42. return *m.Time
  43. }
  44. return ""
  45. }
  46. func (m *CouponRequest) GetSign() string {
  47. if m != nil && m.Sign != nil {
  48. return *m.Sign
  49. }
  50. return ""
  51. }
  52. // 是否可用响应结构
  53. type CouponResponse struct {
  54. Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
  55. Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"`
  56. Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"`
  57. XXX_unrecognized []byte `json:"-"`
  58. }
  59. func (m *CouponResponse) Reset() { *m = CouponResponse{} }
  60. func (m *CouponResponse) String() string { return proto.CompactTextString(m) }
  61. func (*CouponResponse) ProtoMessage() {}
  62. func (m *CouponResponse) GetData() string {
  63. if m != nil && m.Data != nil {
  64. return *m.Data
  65. }
  66. return ""
  67. }
  68. func (m *CouponResponse) GetTime() string {
  69. if m != nil && m.Time != nil {
  70. return *m.Time
  71. }
  72. return ""
  73. }
  74. func (m *CouponResponse) GetSign() string {
  75. if m != nil && m.Sign != nil {
  76. return *m.Sign
  77. }
  78. return ""
  79. }
  80. func init() {
  81. }
  82. type CouponService interface {
  83. IsAvailable(in *CouponRequest, out *CouponResponse) error
  84. Use(in *CouponRequest, out *CouponResponse) error
  85. GetCouponInfo(in *CouponRequest, out *CouponResponse) error
  86. }
  87. // AcceptCouponServiceClient accepts connections on the listener and serves requests
  88. // for each incoming connection. Accept blocks; the caller typically
  89. // invokes it in a go statement.
  90. func AcceptCouponServiceClient(lis net.Listener, x CouponService) {
  91. srv := rpc.NewServer()
  92. if err := srv.RegisterName("CouponService", x); err != nil {
  93. log.Fatal(err)
  94. }
  95. for {
  96. conn, err := lis.Accept()
  97. if err != nil {
  98. log.Fatalf("lis.Accept(): %v\n", err)
  99. }
  100. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  101. }
  102. }
  103. // RegisterCouponService publish the given CouponService implementation on the server.
  104. func RegisterCouponService(srv *rpc.Server, x CouponService) error {
  105. if err := srv.RegisterName("CouponService", x); err != nil {
  106. return err
  107. }
  108. return nil
  109. }
  110. // NewCouponServiceServer returns a new CouponService Server.
  111. func NewCouponServiceServer(x CouponService) *rpc.Server {
  112. srv := rpc.NewServer()
  113. if err := srv.RegisterName("CouponService", x); err != nil {
  114. log.Fatal(err)
  115. }
  116. return srv
  117. }
  118. // ListenAndServeCouponService listen announces on the local network address laddr
  119. // and serves the given CouponService implementation.
  120. func ListenAndServeCouponService(network, addr string, x CouponService) error {
  121. lis, err := net.Listen(network, addr)
  122. if err != nil {
  123. return err
  124. }
  125. defer lis.Close()
  126. srv := rpc.NewServer()
  127. if err := srv.RegisterName("CouponService", x); err != nil {
  128. return err
  129. }
  130. for {
  131. conn, err := lis.Accept()
  132. if err != nil {
  133. log.Fatalf("lis.Accept(): %v\n", err)
  134. }
  135. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  136. }
  137. }
  138. type CouponServiceClient struct {
  139. *rpc.Client
  140. }
  141. // NewCouponServiceClient returns a CouponService rpc.Client and stub to handle
  142. // requests to the set of CouponService at the other end of the connection.
  143. func NewCouponServiceClient(conn io.ReadWriteCloser) (*CouponServiceClient, *rpc.Client) {
  144. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  145. return &CouponServiceClient{c}, c
  146. }
  147. func (c *CouponServiceClient) IsAvailable(in *CouponRequest, out *CouponResponse) error {
  148. return c.Call("CouponService.IsAvailable", in, out)
  149. }
  150. func (c *CouponServiceClient) Use(in *CouponRequest, out *CouponResponse) error {
  151. return c.Call("CouponService.Use", in, out)
  152. }
  153. func (c *CouponServiceClient) GetCouponInfo(in *CouponRequest, out *CouponResponse) error {
  154. return c.Call("CouponService.GetCouponInfo", in, out)
  155. }
  156. // DialCouponService connects to an CouponService at the specified network address.
  157. func DialCouponService(network, addr string) (*CouponServiceClient, *rpc.Client, error) {
  158. c, err := protorpc.Dial(network, addr)
  159. if err != nil {
  160. return nil, nil, err
  161. }
  162. return &CouponServiceClient{c}, c, nil
  163. }
  164. // DialCouponServiceTimeout connects to an CouponService at the specified network address.
  165. func DialCouponServiceTimeout(network, addr string,
  166. timeout time.Duration) (*CouponServiceClient, *rpc.Client, error) {
  167. c, err := protorpc.DialTimeout(network, addr, timeout)
  168. if err != nil {
  169. return nil, nil, err
  170. }
  171. return &CouponServiceClient{c}, c, nil
  172. }