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

167 lines
4.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
  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. Params
  10. */
  11. package supplierrpc
  12. import proto "github.com/chai2010/protorpc/proto"
  13. import math "math"
  14. import "io"
  15. import "log"
  16. import "net"
  17. import "net/rpc"
  18. import "time"
  19. import protorpc "github.com/chai2010/protorpc"
  20. // Reference imports to suppress errors if they are not otherwise used.
  21. var _ = proto.Marshal
  22. var _ = math.Inf
  23. type Params struct {
  24. Data *string `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
  25. Time *string `protobuf:"bytes,2,opt,name=time" json:"time,omitempty"`
  26. Sign *string `protobuf:"bytes,3,opt,name=sign" json:"sign,omitempty"`
  27. XXX_unrecognized []byte `json:"-"`
  28. }
  29. func (m *Params) Reset() { *m = Params{} }
  30. func (m *Params) String() string { return proto.CompactTextString(m) }
  31. func (*Params) ProtoMessage() {}
  32. func (m *Params) GetData() string {
  33. if m != nil && m.Data != nil {
  34. return *m.Data
  35. }
  36. return ""
  37. }
  38. func (m *Params) GetTime() string {
  39. if m != nil && m.Time != nil {
  40. return *m.Time
  41. }
  42. return ""
  43. }
  44. func (m *Params) GetSign() string {
  45. if m != nil && m.Sign != nil {
  46. return *m.Sign
  47. }
  48. return ""
  49. }
  50. func init() {
  51. }
  52. type SupplierService interface {
  53. Get(in *Params, out *Params) error
  54. GetByUuid(in *Params, out *Params) error
  55. IsOpen(in *Params, out *Params) error
  56. }
  57. // AcceptSupplierServiceClient accepts connections on the listener and serves requests
  58. // for each incoming connection. Accept blocks; the caller typically
  59. // invokes it in a go statement.
  60. func AcceptSupplierServiceClient(lis net.Listener, x SupplierService) {
  61. srv := rpc.NewServer()
  62. if err := srv.RegisterName("SupplierService", x); err != nil {
  63. log.Fatal(err)
  64. }
  65. for {
  66. conn, err := lis.Accept()
  67. if err != nil {
  68. log.Fatalf("lis.Accept(): %v\n", err)
  69. }
  70. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  71. }
  72. }
  73. // RegisterSupplierService publish the given SupplierService implementation on the server.
  74. func RegisterSupplierService(srv *rpc.Server, x SupplierService) error {
  75. if err := srv.RegisterName("SupplierService", x); err != nil {
  76. return err
  77. }
  78. return nil
  79. }
  80. // NewSupplierServiceServer returns a new SupplierService Server.
  81. func NewSupplierServiceServer(x SupplierService) *rpc.Server {
  82. srv := rpc.NewServer()
  83. if err := srv.RegisterName("SupplierService", x); err != nil {
  84. log.Fatal(err)
  85. }
  86. return srv
  87. }
  88. // ListenAndServeSupplierService listen announces on the local network address laddr
  89. // and serves the given SupplierService implementation.
  90. func ListenAndServeSupplierService(network, addr string, x SupplierService) error {
  91. lis, err := net.Listen(network, addr)
  92. if err != nil {
  93. return err
  94. }
  95. defer lis.Close()
  96. srv := rpc.NewServer()
  97. if err := srv.RegisterName("SupplierService", x); err != nil {
  98. return err
  99. }
  100. for {
  101. conn, err := lis.Accept()
  102. if err != nil {
  103. log.Fatalf("lis.Accept(): %v\n", err)
  104. }
  105. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  106. }
  107. }
  108. type SupplierServiceClient struct {
  109. *rpc.Client
  110. }
  111. // NewSupplierServiceClient returns a SupplierService rpc.Client and stub to handle
  112. // requests to the set of SupplierService at the other end of the connection.
  113. func NewSupplierServiceClient(conn io.ReadWriteCloser) (*SupplierServiceClient, *rpc.Client) {
  114. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  115. return &SupplierServiceClient{c}, c
  116. }
  117. func (c *SupplierServiceClient) Get(in *Params, out *Params) error {
  118. return c.Call("SupplierService.Get", in, out)
  119. }
  120. func (c *SupplierServiceClient) GetByUuid(in *Params, out *Params) error {
  121. return c.Call("SupplierService.GetByUuid", in, out)
  122. }
  123. func (c *SupplierServiceClient) IsOpen(in *Params, out *Params) error {
  124. return c.Call("SupplierService.IsOpen", in, out)
  125. }
  126. // DialSupplierService connects to an SupplierService at the specified network address.
  127. func DialSupplierService(network, addr string) (*SupplierServiceClient, *rpc.Client, error) {
  128. c, err := protorpc.Dial(network, addr)
  129. if err != nil {
  130. return nil, nil, err
  131. }
  132. return &SupplierServiceClient{c}, c, nil
  133. }
  134. // DialSupplierServiceTimeout connects to an SupplierService at the specified network address.
  135. func DialSupplierServiceTimeout(network, addr string,
  136. timeout time.Duration) (*SupplierServiceClient, *rpc.Client, error) {
  137. c, err := protorpc.DialTimeout(network, addr, timeout)
  138. if err != nil {
  139. return nil, nil, err
  140. }
  141. return &SupplierServiceClient{c}, c, nil
  142. }