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.

194 lines
5.0 KiB

3 years ago
  1. // Code generated by protoc-gen-go.
  2. // source: mastermsg.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package mastermsg is a generated protocol buffer package.
  6. It is generated from these files:
  7. mastermsg.proto
  8. It has these top-level messages:
  9. EventRequest
  10. EventResponse
  11. */
  12. package mastermsg
  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 EventRequest struct {
  26. SiteId *string `protobuf:"bytes,1,opt,name=site_id" json:"site_id,omitempty"`
  27. Domainname *string `protobuf:"bytes,2,opt,name=domainname" json:"domainname,omitempty"`
  28. Type *string `protobuf:"bytes,3,opt,name=type" json:"type,omitempty"`
  29. Memo *string `protobuf:"bytes,4,opt,name=memo" json:"memo,omitempty"`
  30. Data *string `protobuf:"bytes,5,opt,name=data" json:"data,omitempty"`
  31. XXX_unrecognized []byte `json:"-"`
  32. }
  33. func (m *EventRequest) Reset() { *m = EventRequest{} }
  34. func (m *EventRequest) String() string { return proto.CompactTextString(m) }
  35. func (*EventRequest) ProtoMessage() {}
  36. func (m *EventRequest) GetSiteId() string {
  37. if m != nil && m.SiteId != nil {
  38. return *m.SiteId
  39. }
  40. return ""
  41. }
  42. func (m *EventRequest) GetDomainname() string {
  43. if m != nil && m.Domainname != nil {
  44. return *m.Domainname
  45. }
  46. return ""
  47. }
  48. func (m *EventRequest) GetType() string {
  49. if m != nil && m.Type != nil {
  50. return *m.Type
  51. }
  52. return ""
  53. }
  54. func (m *EventRequest) GetMemo() string {
  55. if m != nil && m.Memo != nil {
  56. return *m.Memo
  57. }
  58. return ""
  59. }
  60. func (m *EventRequest) GetData() string {
  61. if m != nil && m.Data != nil {
  62. return *m.Data
  63. }
  64. return ""
  65. }
  66. // 算术运算响应结构
  67. type EventResponse struct {
  68. EventId *string `protobuf:"bytes,1,opt,name=event_id" json:"event_id,omitempty"`
  69. XXX_unrecognized []byte `json:"-"`
  70. }
  71. func (m *EventResponse) Reset() { *m = EventResponse{} }
  72. func (m *EventResponse) String() string { return proto.CompactTextString(m) }
  73. func (*EventResponse) ProtoMessage() {}
  74. func (m *EventResponse) GetEventId() string {
  75. if m != nil && m.EventId != nil {
  76. return *m.EventId
  77. }
  78. return ""
  79. }
  80. func init() {
  81. }
  82. type MsgService interface {
  83. SendEvent(in *EventRequest, out *EventResponse) error
  84. }
  85. // AcceptMsgServiceClient accepts connections on the listener and serves requests
  86. // for each incoming connection. Accept blocks; the caller typically
  87. // invokes it in a go statement.
  88. func AcceptMsgServiceClient(lis net.Listener, x MsgService) {
  89. srv := rpc.NewServer()
  90. if err := srv.RegisterName("MsgService", x); err != nil {
  91. log.Fatal(err)
  92. }
  93. for {
  94. conn, err := lis.Accept()
  95. if err != nil {
  96. log.Fatalf("lis.Accept(): %v\n", err)
  97. }
  98. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  99. }
  100. }
  101. // RegisterMsgService publish the given MsgService implementation on the server.
  102. func RegisterMsgService(srv *rpc.Server, x MsgService) error {
  103. if err := srv.RegisterName("MsgService", x); err != nil {
  104. return err
  105. }
  106. return nil
  107. }
  108. // NewMsgServiceServer returns a new MsgService Server.
  109. func NewMsgServiceServer(x MsgService) *rpc.Server {
  110. srv := rpc.NewServer()
  111. if err := srv.RegisterName("MsgService", x); err != nil {
  112. log.Fatal(err)
  113. }
  114. return srv
  115. }
  116. // ListenAndServeMsgService listen announces on the local network address laddr
  117. // and serves the given MsgService implementation.
  118. func ListenAndServeMsgService(network, addr string, x MsgService) error {
  119. lis, err := net.Listen(network, addr)
  120. if err != nil {
  121. return err
  122. }
  123. defer lis.Close()
  124. srv := rpc.NewServer()
  125. if err := srv.RegisterName("MsgService", x); err != nil {
  126. return err
  127. }
  128. for {
  129. conn, err := lis.Accept()
  130. if err != nil {
  131. log.Fatalf("lis.Accept(): %v\n", err)
  132. }
  133. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  134. }
  135. }
  136. type MsgServiceClient struct {
  137. *rpc.Client
  138. }
  139. // NewMsgServiceClient returns a MsgService rpc.Client and stub to handle
  140. // requests to the set of MsgService at the other end of the connection.
  141. func NewMsgServiceClient(conn io.ReadWriteCloser) (*MsgServiceClient, *rpc.Client) {
  142. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  143. return &MsgServiceClient{c}, c
  144. }
  145. func (c *MsgServiceClient) SendEvent(in *EventRequest, out *EventResponse) error {
  146. return c.Call("MsgService.SendEvent", in, out)
  147. }
  148. // DialMsgService connects to an MsgService at the specified network address.
  149. func DialMsgService(network, addr string) (*MsgServiceClient, *rpc.Client, error) {
  150. c, err := protorpc.Dial(network, addr)
  151. if err != nil {
  152. return nil, nil, err
  153. }
  154. return &MsgServiceClient{c}, c, nil
  155. }
  156. // DialMsgServiceTimeout connects to an MsgService at the specified network address.
  157. func DialMsgServiceTimeout(network, addr string,
  158. timeout time.Duration) (*MsgServiceClient, *rpc.Client, error) {
  159. c, err := protorpc.DialTimeout(network, addr, timeout)
  160. if err != nil {
  161. return nil, nil, err
  162. }
  163. return &MsgServiceClient{c}, c, nil
  164. }