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

311 lines
8.2 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. }
  175. // AcceptProductServiceClient accepts connections on the listener and serves requests
  176. // for each incoming connection. Accept blocks; the caller typically
  177. // invokes it in a go statement.
  178. func AcceptProductServiceClient(lis net.Listener, x ProductService) {
  179. srv := rpc.NewServer()
  180. if err := srv.RegisterName("ProductService", x); err != nil {
  181. log.Fatal(err)
  182. }
  183. for {
  184. conn, err := lis.Accept()
  185. if err != nil {
  186. log.Fatalf("lis.Accept(): %v\n", err)
  187. }
  188. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  189. }
  190. }
  191. // RegisterProductService publish the given ProductService implementation on the server.
  192. func RegisterProductService(srv *rpc.Server, x ProductService) error {
  193. if err := srv.RegisterName("ProductService", x); err != nil {
  194. return err
  195. }
  196. return nil
  197. }
  198. // NewProductServiceServer returns a new ProductService Server.
  199. func NewProductServiceServer(x ProductService) *rpc.Server {
  200. srv := rpc.NewServer()
  201. if err := srv.RegisterName("ProductService", x); err != nil {
  202. log.Fatal(err)
  203. }
  204. return srv
  205. }
  206. // ListenAndServeProductService listen announces on the local network address laddr
  207. // and serves the given ProductService implementation.
  208. func ListenAndServeProductService(network, addr string, x ProductService) error {
  209. lis, err := net.Listen(network, addr)
  210. if err != nil {
  211. return err
  212. }
  213. defer lis.Close()
  214. srv := rpc.NewServer()
  215. if err := srv.RegisterName("ProductService", x); err != nil {
  216. return err
  217. }
  218. for {
  219. conn, err := lis.Accept()
  220. if err != nil {
  221. log.Fatalf("lis.Accept(): %v\n", err)
  222. }
  223. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  224. }
  225. }
  226. type ProductServiceClient struct {
  227. *rpc.Client
  228. }
  229. // NewProductServiceClient returns a ProductService rpc.Client and stub to handle
  230. // requests to the set of ProductService at the other end of the connection.
  231. func NewProductServiceClient(conn io.ReadWriteCloser) (*ProductServiceClient, *rpc.Client) {
  232. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  233. return &ProductServiceClient{c}, c
  234. }
  235. func (c *ProductServiceClient) Get(in *GetRequest, out *GetResponse) error {
  236. return c.Call("ProductService.Get", in, out)
  237. }
  238. func (c *ProductServiceClient) GetByUuid(in *GetUuidRequest, out *GetResponse) error {
  239. return c.Call("ProductService.GetByUuid", in, out)
  240. }
  241. func (c *ProductServiceClient) GetSku(in *GetRequest, out *GetResponse) error {
  242. return c.Call("ProductService.GetSku", in, out)
  243. }
  244. func (c *ProductServiceClient) GetSkuByUuid(in *GetUuidRequest, out *GetResponse) error {
  245. return c.Call("ProductService.GetSkuByUuid", in, out)
  246. }
  247. func (c *ProductServiceClient) GetActivity(in *Request, out *Response) error {
  248. return c.Call("ProductService.GetActivity", in, out)
  249. }
  250. // DialProductService connects to an ProductService at the specified network address.
  251. func DialProductService(network, addr string) (*ProductServiceClient, *rpc.Client, error) {
  252. c, err := protorpc.Dial(network, addr)
  253. if err != nil {
  254. return nil, nil, err
  255. }
  256. return &ProductServiceClient{c}, c, nil
  257. }
  258. // DialProductServiceTimeout connects to an ProductService at the specified network address.
  259. func DialProductServiceTimeout(network, addr string,
  260. timeout time.Duration) (*ProductServiceClient, *rpc.Client, error) {
  261. c, err := protorpc.DialTimeout(network, addr, timeout)
  262. if err != nil {
  263. return nil, nil, err
  264. }
  265. return &ProductServiceClient{c}, c, nil
  266. }