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

335 lines
9.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. Request
  13. Response
  14. */
  15. package productrpc
  16. import proto "github.com/chai2010/protorpc/proto"
  17. import math "math"
  18. import "io"
  19. import "log"
  20. import "net"
  21. import "net/rpc"
  22. import "time"
  23. import protorpc "github.com/chai2010/protorpc"
  24. // Reference imports to suppress errors if they are not otherwise used.
  25. var _ = proto.Marshal
  26. var _ = math.Inf
  27. // 使用key查询
  28. type GetRequest struct {
  29. SiteId *string `protobuf:"bytes,1,opt,name=site_id" json:"site_id,omitempty"`
  30. Dbname *string `protobuf:"bytes,2,opt,name=dbname" json:"dbname,omitempty"`
  31. Id *string `protobuf:"bytes,3,opt,name=id" json:"id,omitempty"`
  32. Field *string `protobuf:"bytes,4,opt,name=field" json:"field,omitempty"`
  33. XXX_unrecognized []byte `json:"-"`
  34. }
  35. func (m *GetRequest) Reset() { *m = GetRequest{} }
  36. func (m *GetRequest) String() string { return proto.CompactTextString(m) }
  37. func (*GetRequest) ProtoMessage() {}
  38. func (m *GetRequest) GetSiteId() string {
  39. if m != nil && m.SiteId != nil {
  40. return *m.SiteId
  41. }
  42. return ""
  43. }
  44. func (m *GetRequest) GetDbname() string {
  45. if m != nil && m.Dbname != nil {
  46. return *m.Dbname
  47. }
  48. return ""
  49. }
  50. func (m *GetRequest) GetId() string {
  51. if m != nil && m.Id != nil {
  52. return *m.Id
  53. }
  54. return ""
  55. }
  56. func (m *GetRequest) GetField() string {
  57. if m != nil && m.Field != nil {
  58. return *m.Field
  59. }
  60. return ""
  61. }
  62. type GetUuidRequest struct {
  63. SiteId *string `protobuf:"bytes,1,opt,name=site_id" json:"site_id,omitempty"`
  64. Dbname *string `protobuf:"bytes,2,opt,name=dbname" json:"dbname,omitempty"`
  65. Uuid *string `protobuf:"bytes,3,opt,name=uuid" json:"uuid,omitempty"`
  66. Field *string `protobuf:"bytes,4,opt,name=field" json:"field,omitempty"`
  67. XXX_unrecognized []byte `json:"-"`
  68. }
  69. func (m *GetUuidRequest) Reset() { *m = GetUuidRequest{} }
  70. func (m *GetUuidRequest) String() string { return proto.CompactTextString(m) }
  71. func (*GetUuidRequest) ProtoMessage() {}
  72. func (m *GetUuidRequest) GetSiteId() string {
  73. if m != nil && m.SiteId != nil {
  74. return *m.SiteId
  75. }
  76. return ""
  77. }
  78. func (m *GetUuidRequest) GetDbname() string {
  79. if m != nil && m.Dbname != nil {
  80. return *m.Dbname
  81. }
  82. return ""
  83. }
  84. func (m *GetUuidRequest) GetUuid() string {
  85. if m != nil && m.Uuid != nil {
  86. return *m.Uuid
  87. }
  88. return ""
  89. }
  90. func (m *GetUuidRequest) GetField() string {
  91. if m != nil && m.Field != nil {
  92. return *m.Field
  93. }
  94. return ""
  95. }
  96. // 使用key查询响应结构
  97. type GetResponse struct {
  98. Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
  99. XXX_unrecognized []byte `json:"-"`
  100. }
  101. func (m *GetResponse) Reset() { *m = GetResponse{} }
  102. func (m *GetResponse) String() string { return proto.CompactTextString(m) }
  103. func (*GetResponse) ProtoMessage() {}
  104. func (m *GetResponse) GetValue() []byte {
  105. if m != nil {
  106. return m.Value
  107. }
  108. return nil
  109. }
  110. // 配置信息请求结构
  111. type Request struct {
  112. Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
  113. Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"`
  114. Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"`
  115. XXX_unrecognized []byte `json:"-"`
  116. }
  117. func (m *Request) Reset() { *m = Request{} }
  118. func (m *Request) String() string { return proto.CompactTextString(m) }
  119. func (*Request) ProtoMessage() {}
  120. func (m *Request) GetData() string {
  121. if m != nil && m.Data != nil {
  122. return *m.Data
  123. }
  124. return ""
  125. }
  126. func (m *Request) GetTime() string {
  127. if m != nil && m.Time != nil {
  128. return *m.Time
  129. }
  130. return ""
  131. }
  132. func (m *Request) GetSign() string {
  133. if m != nil && m.Sign != nil {
  134. return *m.Sign
  135. }
  136. return ""
  137. }
  138. // 配置信息响应结构
  139. type Response struct {
  140. Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
  141. Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"`
  142. Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"`
  143. XXX_unrecognized []byte `json:"-"`
  144. }
  145. func (m *Response) Reset() { *m = Response{} }
  146. func (m *Response) String() string { return proto.CompactTextString(m) }
  147. func (*Response) ProtoMessage() {}
  148. func (m *Response) GetData() string {
  149. if m != nil && m.Data != nil {
  150. return *m.Data
  151. }
  152. return ""
  153. }
  154. func (m *Response) GetTime() string {
  155. if m != nil && m.Time != nil {
  156. return *m.Time
  157. }
  158. return ""
  159. }
  160. func (m *Response) GetSign() string {
  161. if m != nil && m.Sign != nil {
  162. return *m.Sign
  163. }
  164. return ""
  165. }
  166. func init() {
  167. }
  168. type ProductService interface {
  169. Get(in *GetRequest, out *GetResponse) error
  170. GetByUuid(in *GetUuidRequest, out *GetResponse) error
  171. GetSku(in *GetRequest, out *GetResponse) error
  172. GetSkuByUuid(in *GetUuidRequest, out *GetResponse) error
  173. GetActivity(in *Request, out *Response) error
  174. GetAllActivity(in *Request, out *Response) error
  175. GetWarmingActivity(in *Request, out *Response) error
  176. FavoriteProduct(in *Request, out *Response) error
  177. GetProductActivity(in *Request, out *Response) error
  178. GetProductAllActivity(in *Request, out *Response) error
  179. GetProductWarmingActivity(in *Request, out *Response) error
  180. }
  181. // AcceptProductServiceClient accepts connections on the listener and serves requests
  182. // for each incoming connection. Accept blocks; the caller typically
  183. // invokes it in a go statement.
  184. func AcceptProductServiceClient(lis net.Listener, x ProductService) {
  185. srv := rpc.NewServer()
  186. if err := srv.RegisterName("ProductService", x); err != nil {
  187. log.Fatal(err)
  188. }
  189. for {
  190. conn, err := lis.Accept()
  191. if err != nil {
  192. log.Fatalf("lis.Accept(): %v\n", err)
  193. }
  194. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  195. }
  196. }
  197. // RegisterProductService publish the given ProductService implementation on the server.
  198. func RegisterProductService(srv *rpc.Server, x ProductService) error {
  199. if err := srv.RegisterName("ProductService", x); err != nil {
  200. return err
  201. }
  202. return nil
  203. }
  204. // NewProductServiceServer returns a new ProductService Server.
  205. func NewProductServiceServer(x ProductService) *rpc.Server {
  206. srv := rpc.NewServer()
  207. if err := srv.RegisterName("ProductService", x); err != nil {
  208. log.Fatal(err)
  209. }
  210. return srv
  211. }
  212. // ListenAndServeProductService listen announces on the local network address laddr
  213. // and serves the given ProductService implementation.
  214. func ListenAndServeProductService(network, addr string, x ProductService) error {
  215. lis, err := net.Listen(network, addr)
  216. if err != nil {
  217. return err
  218. }
  219. defer lis.Close()
  220. srv := rpc.NewServer()
  221. if err := srv.RegisterName("ProductService", x); err != nil {
  222. return err
  223. }
  224. for {
  225. conn, err := lis.Accept()
  226. if err != nil {
  227. log.Fatalf("lis.Accept(): %v\n", err)
  228. }
  229. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  230. }
  231. }
  232. type ProductServiceClient struct {
  233. *rpc.Client
  234. }
  235. // NewProductServiceClient returns a ProductService rpc.Client and stub to handle
  236. // requests to the set of ProductService at the other end of the connection.
  237. func NewProductServiceClient(conn io.ReadWriteCloser) (*ProductServiceClient, *rpc.Client) {
  238. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  239. return &ProductServiceClient{c}, c
  240. }
  241. func (c *ProductServiceClient) Get(in *GetRequest, out *GetResponse) error {
  242. return c.Call("ProductService.Get", in, out)
  243. }
  244. func (c *ProductServiceClient) GetByUuid(in *GetUuidRequest, out *GetResponse) error {
  245. return c.Call("ProductService.GetByUuid", in, out)
  246. }
  247. func (c *ProductServiceClient) GetSku(in *GetRequest, out *GetResponse) error {
  248. return c.Call("ProductService.GetSku", in, out)
  249. }
  250. func (c *ProductServiceClient) GetSkuByUuid(in *GetUuidRequest, out *GetResponse) error {
  251. return c.Call("ProductService.GetSkuByUuid", in, out)
  252. }
  253. func (c *ProductServiceClient) GetActivity(in *Request, out *Response) error {
  254. return c.Call("ProductService.GetActivity", in, out)
  255. }
  256. func (c *ProductServiceClient) GetAllActivity(in *Request, out *Response) error {
  257. return c.Call("ProductService.GetAllActivity", in, out)
  258. }
  259. func (c *ProductServiceClient) GetWarmingActivity(in *Request, out *Response) error {
  260. return c.Call("ProductService.GetWarmingActivity", in, out)
  261. }
  262. func (c *ProductServiceClient) FavoriteProduct(in *Request, out *Response) error {
  263. return c.Call("ProductService.FavoriteProduct", in, out)
  264. }
  265. func (c *ProductServiceClient) GetProductActivity(in *Request, out *Response) error {
  266. return c.Call("ProductService.GetProductActivity", in, out)
  267. }
  268. func (c *ProductServiceClient) GetProductAllActivity(in *Request, out *Response) error {
  269. return c.Call("ProductService.GetProductAllActivity", in, out)
  270. }
  271. func (c *ProductServiceClient) GetProductWarmingActivity(in *Request, out *Response) error {
  272. return c.Call("ProductService.GetProductWarmingActivity", in, out)
  273. }
  274. // DialProductService connects to an ProductService at the specified network address.
  275. func DialProductService(network, addr string) (*ProductServiceClient, *rpc.Client, error) {
  276. c, err := protorpc.Dial(network, addr)
  277. if err != nil {
  278. return nil, nil, err
  279. }
  280. return &ProductServiceClient{c}, c, nil
  281. }
  282. // DialProductServiceTimeout connects to an ProductService at the specified network address.
  283. func DialProductServiceTimeout(network, addr string,
  284. timeout time.Duration) (*ProductServiceClient, *rpc.Client, error) {
  285. c, err := protorpc.DialTimeout(network, addr, timeout)
  286. if err != nil {
  287. return nil, nil, err
  288. }
  289. return &ProductServiceClient{c}, c, nil
  290. }