rabbitmq 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.

198 lines
5.2 KiB

  1. // Code generated by protoc-gen-go.
  2. // source: rabbitmq.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package rabbitmqrpc is a generated protocol buffer package.
  6. It is generated from these files:
  7. rabbitmq.proto
  8. It has these top-level messages:
  9. Request
  10. Response
  11. */
  12. package rabbitmqrpc
  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 RabbitmqService interface {
  83. Send(in *Request, out *Response) error
  84. SendDelay(in *Request, out *Response) error
  85. }
  86. // AcceptRabbitmqServiceClient accepts connections on the listener and serves requests
  87. // for each incoming connection. Accept blocks; the caller typically
  88. // invokes it in a go statement.
  89. func AcceptRabbitmqServiceClient(lis net.Listener, x RabbitmqService) {
  90. srv := rpc.NewServer()
  91. if err := srv.RegisterName("RabbitmqService", x); err != nil {
  92. log.Fatal(err)
  93. }
  94. for {
  95. conn, err := lis.Accept()
  96. if err != nil {
  97. log.Fatalf("lis.Accept(): %v\n", err)
  98. }
  99. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  100. }
  101. }
  102. // RegisterRabbitmqService publish the given RabbitmqService implementation on the server.
  103. func RegisterRabbitmqService(srv *rpc.Server, x RabbitmqService) error {
  104. if err := srv.RegisterName("RabbitmqService", x); err != nil {
  105. return err
  106. }
  107. return nil
  108. }
  109. // NewRabbitmqServiceServer returns a new RabbitmqService Server.
  110. func NewRabbitmqServiceServer(x RabbitmqService) *rpc.Server {
  111. srv := rpc.NewServer()
  112. if err := srv.RegisterName("RabbitmqService", x); err != nil {
  113. log.Fatal(err)
  114. }
  115. return srv
  116. }
  117. // ListenAndServeRabbitmqService listen announces on the local network address laddr
  118. // and serves the given RabbitmqService implementation.
  119. func ListenAndServeRabbitmqService(network, addr string, x RabbitmqService) error {
  120. lis, err := net.Listen(network, addr)
  121. if err != nil {
  122. return err
  123. }
  124. defer lis.Close()
  125. srv := rpc.NewServer()
  126. if err := srv.RegisterName("RabbitmqService", x); err != nil {
  127. return err
  128. }
  129. for {
  130. conn, err := lis.Accept()
  131. if err != nil {
  132. log.Fatalf("lis.Accept(): %v\n", err)
  133. }
  134. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  135. }
  136. }
  137. type RabbitmqServiceClient struct {
  138. *rpc.Client
  139. }
  140. // NewRabbitmqServiceClient returns a RabbitmqService rpc.Client and stub to handle
  141. // requests to the set of RabbitmqService at the other end of the connection.
  142. func NewRabbitmqServiceClient(conn io.ReadWriteCloser) (*RabbitmqServiceClient, *rpc.Client) {
  143. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  144. return &RabbitmqServiceClient{c}, c
  145. }
  146. func (c *RabbitmqServiceClient) Send(in *Request, out *Response) error {
  147. return c.Call("RabbitmqService.Send", in, out)
  148. }
  149. func (c *RabbitmqServiceClient) SendDelay(in *Request, out *Response) error {
  150. return c.Call("RabbitmqService.SendDelay", in, out)
  151. }
  152. // DialRabbitmqService connects to an RabbitmqService at the specified network address.
  153. func DialRabbitmqService(network, addr string) (*RabbitmqServiceClient, *rpc.Client, error) {
  154. c, err := protorpc.Dial(network, addr)
  155. if err != nil {
  156. return nil, nil, err
  157. }
  158. return &RabbitmqServiceClient{c}, c, nil
  159. }
  160. // DialRabbitmqServiceTimeout connects to an RabbitmqService at the specified network address.
  161. func DialRabbitmqServiceTimeout(network, addr string,
  162. timeout time.Duration) (*RabbitmqServiceClient, *rpc.Client, error) {
  163. c, err := protorpc.DialTimeout(network, addr, timeout)
  164. if err != nil {
  165. return nil, nil, err
  166. }
  167. return &RabbitmqServiceClient{c}, c, nil
  168. }