商品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.

239 lines
6.4 KiB

  1. // Code generated by protoc-gen-go.
  2. // source: product.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package productrpc is a generated protocol buffer package.
  6. It is generated from these files:
  7. product.proto
  8. It has these top-level messages:
  9. GetRequest
  10. GetUuidRequest
  11. GetResponse
  12. */
  13. package productrpc
  14. import proto "github.com/chai2010/protorpc/proto"
  15. import math "math"
  16. import "io"
  17. import "log"
  18. import "net"
  19. import "net/rpc"
  20. import "time"
  21. import protorpc "github.com/chai2010/protorpc"
  22. // Reference imports to suppress errors if they are not otherwise used.
  23. var _ = proto.Marshal
  24. var _ = math.Inf
  25. // 使用key查询
  26. type GetRequest struct {
  27. SiteId *string `protobuf:"bytes,1,opt,name=site_id" json:"site_id,omitempty"`
  28. Dbname *string `protobuf:"bytes,2,opt,name=dbname" json:"dbname,omitempty"`
  29. Id *string `protobuf:"bytes,3,opt,name=id" json:"id,omitempty"`
  30. Field *string `protobuf:"bytes,4,opt,name=field" json:"field,omitempty"`
  31. XXX_unrecognized []byte `json:"-"`
  32. }
  33. func (m *GetRequest) Reset() { *m = GetRequest{} }
  34. func (m *GetRequest) String() string { return proto.CompactTextString(m) }
  35. func (*GetRequest) ProtoMessage() {}
  36. func (m *GetRequest) GetSiteId() string {
  37. if m != nil && m.SiteId != nil {
  38. return *m.SiteId
  39. }
  40. return ""
  41. }
  42. func (m *GetRequest) GetDbname() string {
  43. if m != nil && m.Dbname != nil {
  44. return *m.Dbname
  45. }
  46. return ""
  47. }
  48. func (m *GetRequest) GetId() string {
  49. if m != nil && m.Id != nil {
  50. return *m.Id
  51. }
  52. return ""
  53. }
  54. func (m *GetRequest) GetField() string {
  55. if m != nil && m.Field != nil {
  56. return *m.Field
  57. }
  58. return ""
  59. }
  60. type GetUuidRequest struct {
  61. SiteId *string `protobuf:"bytes,1,opt,name=site_id" json:"site_id,omitempty"`
  62. Dbname *string `protobuf:"bytes,2,opt,name=dbname" json:"dbname,omitempty"`
  63. Id *string `protobuf:"bytes,3,opt,name=id" json:"id,omitempty"`
  64. Field *string `protobuf:"bytes,4,opt,name=field" json:"field,omitempty"`
  65. XXX_unrecognized []byte `json:"-"`
  66. }
  67. func (m *GetUuidRequest) Reset() { *m = GetUuidRequest{} }
  68. func (m *GetUuidRequest) String() string { return proto.CompactTextString(m) }
  69. func (*GetUuidRequest) ProtoMessage() {}
  70. func (m *GetUuidRequest) GetSiteId() string {
  71. if m != nil && m.SiteId != nil {
  72. return *m.SiteId
  73. }
  74. return ""
  75. }
  76. func (m *GetUuidRequest) GetDbname() string {
  77. if m != nil && m.Dbname != nil {
  78. return *m.Dbname
  79. }
  80. return ""
  81. }
  82. func (m *GetUuidRequest) GetId() string {
  83. if m != nil && m.Id != nil {
  84. return *m.Id
  85. }
  86. return ""
  87. }
  88. func (m *GetUuidRequest) GetField() string {
  89. if m != nil && m.Field != nil {
  90. return *m.Field
  91. }
  92. return ""
  93. }
  94. // 使用key查询响应结构
  95. type GetResponse struct {
  96. Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
  97. XXX_unrecognized []byte `json:"-"`
  98. }
  99. func (m *GetResponse) Reset() { *m = GetResponse{} }
  100. func (m *GetResponse) String() string { return proto.CompactTextString(m) }
  101. func (*GetResponse) ProtoMessage() {}
  102. func (m *GetResponse) GetValue() []byte {
  103. if m != nil {
  104. return m.Value
  105. }
  106. return nil
  107. }
  108. func init() {
  109. }
  110. type ProductService interface {
  111. Get(in *GetRequest, out *GetResponse) error
  112. GetByUuid(in *GetUuidRequest, out *GetResponse) error
  113. GetSku(in *GetRequest, out *GetResponse) error
  114. GetSkuByUuid(in *GetUuidRequest, out *GetResponse) error
  115. }
  116. // AcceptProductServiceClient accepts connections on the listener and serves requests
  117. // for each incoming connection. Accept blocks; the caller typically
  118. // invokes it in a go statement.
  119. func AcceptProductServiceClient(lis net.Listener, x ProductService) {
  120. srv := rpc.NewServer()
  121. if err := srv.RegisterName("ProductService", x); err != nil {
  122. log.Fatal(err)
  123. }
  124. for {
  125. conn, err := lis.Accept()
  126. if err != nil {
  127. log.Fatalf("lis.Accept(): %v\n", err)
  128. }
  129. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  130. }
  131. }
  132. // RegisterProductService publish the given ProductService implementation on the server.
  133. func RegisterProductService(srv *rpc.Server, x ProductService) error {
  134. if err := srv.RegisterName("ProductService", x); err != nil {
  135. return err
  136. }
  137. return nil
  138. }
  139. // NewProductServiceServer returns a new ProductService Server.
  140. func NewProductServiceServer(x ProductService) *rpc.Server {
  141. srv := rpc.NewServer()
  142. if err := srv.RegisterName("ProductService", x); err != nil {
  143. log.Fatal(err)
  144. }
  145. return srv
  146. }
  147. // ListenAndServeProductService listen announces on the local network address laddr
  148. // and serves the given ProductService implementation.
  149. func ListenAndServeProductService(network, addr string, x ProductService) error {
  150. lis, err := net.Listen(network, addr)
  151. if err != nil {
  152. return err
  153. }
  154. defer lis.Close()
  155. srv := rpc.NewServer()
  156. if err := srv.RegisterName("ProductService", x); err != nil {
  157. return err
  158. }
  159. for {
  160. conn, err := lis.Accept()
  161. if err != nil {
  162. log.Fatalf("lis.Accept(): %v\n", err)
  163. }
  164. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  165. }
  166. }
  167. type ProductServiceClient struct {
  168. *rpc.Client
  169. }
  170. // NewProductServiceClient returns a ProductService rpc.Client and stub to handle
  171. // requests to the set of ProductService at the other end of the connection.
  172. func NewProductServiceClient(conn io.ReadWriteCloser) (*ProductServiceClient, *rpc.Client) {
  173. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  174. return &ProductServiceClient{c}, c
  175. }
  176. func (c *ProductServiceClient) Get(in *GetRequest, out *GetResponse) error {
  177. return c.Call("ProductService.Get", in, out)
  178. }
  179. func (c *ProductServiceClient) GetByUuid(in *GetUuidRequest, out *GetResponse) error {
  180. return c.Call("ProductService.GetByUuid", in, out)
  181. }
  182. func (c *ProductServiceClient) GetSku(in *GetRequest, out *GetResponse) error {
  183. return c.Call("ProductService.GetSku", in, out)
  184. }
  185. func (c *ProductServiceClient) GetSkuByUuid(in *GetUuidRequest, out *GetResponse) error {
  186. return c.Call("ProductService.GetSkuByUuid", in, out)
  187. }
  188. // DialProductService connects to an ProductService at the specified network address.
  189. func DialProductService(network, addr string) (*ProductServiceClient, *rpc.Client, error) {
  190. c, err := protorpc.Dial(network, addr)
  191. if err != nil {
  192. return nil, nil, err
  193. }
  194. return &ProductServiceClient{c}, c, nil
  195. }
  196. // DialProductServiceTimeout connects to an ProductService at the specified network address.
  197. func DialProductServiceTimeout(network, addr string,
  198. timeout time.Duration) (*ProductServiceClient, *rpc.Client, error) {
  199. c, err := protorpc.DialTimeout(network, addr, timeout)
  200. if err != nil {
  201. return nil, nil, err
  202. }
  203. return &ProductServiceClient{c}, c, nil
  204. }