供应商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.

206 lines
5.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. // Code generated by protoc-gen-go.
  2. // source: supplier.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package supplierrpc is a generated protocol buffer package.
  6. It is generated from these files:
  7. supplier.proto
  8. It has these top-level messages:
  9. Request
  10. Response
  11. */
  12. package supplierrpc
  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 Request 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 *Request) Reset() { *m = Request{} }
  32. func (m *Request) String() string { return proto.CompactTextString(m) }
  33. func (*Request) ProtoMessage() {}
  34. func (m *Request) GetData() string {
  35. if m != nil && m.Data != nil {
  36. return *m.Data
  37. }
  38. return ""
  39. }
  40. func (m *Request) GetTime() string {
  41. if m != nil && m.Time != nil {
  42. return *m.Time
  43. }
  44. return ""
  45. }
  46. func (m *Request) GetSign() string {
  47. if m != nil && m.Sign != nil {
  48. return *m.Sign
  49. }
  50. return ""
  51. }
  52. // 配置信息响应结构
  53. type Response 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 *Response) Reset() { *m = Response{} }
  60. func (m *Response) String() string { return proto.CompactTextString(m) }
  61. func (*Response) ProtoMessage() {}
  62. func (m *Response) GetData() string {
  63. if m != nil && m.Data != nil {
  64. return *m.Data
  65. }
  66. return ""
  67. }
  68. func (m *Response) GetTime() string {
  69. if m != nil && m.Time != nil {
  70. return *m.Time
  71. }
  72. return ""
  73. }
  74. func (m *Response) GetSign() string {
  75. if m != nil && m.Sign != nil {
  76. return *m.Sign
  77. }
  78. return ""
  79. }
  80. func init() {
  81. }
  82. type SupplierService interface {
  83. Get(in *Request, out *Response) error
  84. GetByUuid(in *Request, out *Response) error
  85. IsOpen(in *Request, out *Response) error
  86. Get380Star(in *Request, out *Response) error
  87. }
  88. // AcceptSupplierServiceClient accepts connections on the listener and serves requests
  89. // for each incoming connection. Accept blocks; the caller typically
  90. // invokes it in a go statement.
  91. func AcceptSupplierServiceClient(lis net.Listener, x SupplierService) {
  92. srv := rpc.NewServer()
  93. if err := srv.RegisterName("SupplierService", x); err != nil {
  94. log.Fatal(err)
  95. }
  96. for {
  97. conn, err := lis.Accept()
  98. if err != nil {
  99. log.Fatalf("lis.Accept(): %v\n", err)
  100. }
  101. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  102. }
  103. }
  104. // RegisterSupplierService publish the given SupplierService implementation on the server.
  105. func RegisterSupplierService(srv *rpc.Server, x SupplierService) error {
  106. if err := srv.RegisterName("SupplierService", x); err != nil {
  107. return err
  108. }
  109. return nil
  110. }
  111. // NewSupplierServiceServer returns a new SupplierService Server.
  112. func NewSupplierServiceServer(x SupplierService) *rpc.Server {
  113. srv := rpc.NewServer()
  114. if err := srv.RegisterName("SupplierService", x); err != nil {
  115. log.Fatal(err)
  116. }
  117. return srv
  118. }
  119. // ListenAndServeSupplierService listen announces on the local network address laddr
  120. // and serves the given SupplierService implementation.
  121. func ListenAndServeSupplierService(network, addr string, x SupplierService) error {
  122. lis, err := net.Listen(network, addr)
  123. if err != nil {
  124. return err
  125. }
  126. defer lis.Close()
  127. srv := rpc.NewServer()
  128. if err := srv.RegisterName("SupplierService", x); err != nil {
  129. return err
  130. }
  131. for {
  132. conn, err := lis.Accept()
  133. if err != nil {
  134. log.Fatalf("lis.Accept(): %v\n", err)
  135. }
  136. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  137. }
  138. }
  139. type SupplierServiceClient struct {
  140. *rpc.Client
  141. }
  142. // NewSupplierServiceClient returns a SupplierService rpc.Client and stub to handle
  143. // requests to the set of SupplierService at the other end of the connection.
  144. func NewSupplierServiceClient(conn io.ReadWriteCloser) (*SupplierServiceClient, *rpc.Client) {
  145. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  146. return &SupplierServiceClient{c}, c
  147. }
  148. func (c *SupplierServiceClient) Get(in *Request, out *Response) error {
  149. return c.Call("SupplierService.Get", in, out)
  150. }
  151. func (c *SupplierServiceClient) GetByUuid(in *Request, out *Response) error {
  152. return c.Call("SupplierService.GetByUuid", in, out)
  153. }
  154. func (c *SupplierServiceClient) IsOpen(in *Request, out *Response) error {
  155. return c.Call("SupplierService.IsOpen", in, out)
  156. }
  157. func (c *SupplierServiceClient) Get380Star(in *Request, out *Response) error {
  158. return c.Call("SupplierService.Get380Star", in, out)
  159. }
  160. // DialSupplierService connects to an SupplierService at the specified network address.
  161. func DialSupplierService(network, addr string) (*SupplierServiceClient, *rpc.Client, error) {
  162. c, err := protorpc.Dial(network, addr)
  163. if err != nil {
  164. return nil, nil, err
  165. }
  166. return &SupplierServiceClient{c}, c, nil
  167. }
  168. // DialSupplierServiceTimeout connects to an SupplierService at the specified network address.
  169. func DialSupplierServiceTimeout(network, addr string,
  170. timeout time.Duration) (*SupplierServiceClient, *rpc.Client, error) {
  171. c, err := protorpc.DialTimeout(network, addr, timeout)
  172. if err != nil {
  173. return nil, nil, err
  174. }
  175. return &SupplierServiceClient{c}, c, nil
  176. }