站点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.

210 lines
5.6 KiB

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