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.

410 lines
11 KiB

3 years ago
  1. // Code generated by protoc-gen-go.
  2. // source: user.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package user is a generated protocol buffer package.
  6. It is generated from these files:
  7. user.proto
  8. It has these top-level messages:
  9. UserRequest
  10. UserResponse
  11. LoginRequest
  12. LoginResponse
  13. */
  14. package user
  15. import proto "github.com/chai2010/protorpc/proto"
  16. import math "math"
  17. import "io"
  18. import "log"
  19. import "net"
  20. import "net/rpc"
  21. import "time"
  22. import protorpc "github.com/chai2010/protorpc"
  23. // Reference imports to suppress errors if they are not otherwise used.
  24. var _ = proto.Marshal
  25. var _ = math.Inf
  26. // 使用token查询用户信息请求结构
  27. type UserRequest struct {
  28. Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
  29. Token *string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
  30. XXX_unrecognized []byte `json:"-"`
  31. }
  32. func (m *UserRequest) Reset() { *m = UserRequest{} }
  33. func (m *UserRequest) String() string { return proto.CompactTextString(m) }
  34. func (*UserRequest) ProtoMessage() {}
  35. func (m *UserRequest) GetDbname() string {
  36. if m != nil && m.Dbname != nil {
  37. return *m.Dbname
  38. }
  39. return ""
  40. }
  41. func (m *UserRequest) GetToken() string {
  42. if m != nil && m.Token != nil {
  43. return *m.Token
  44. }
  45. return ""
  46. }
  47. // 使用token查询用户信息响应结构
  48. type UserResponse struct {
  49. UserId *string `protobuf:"bytes,1,opt,name=user_id" json:"user_id,omitempty"`
  50. Username *string `protobuf:"bytes,2,opt,name=username" json:"username,omitempty"`
  51. Nickname *string `protobuf:"bytes,3,opt,name=nickname" json:"nickname,omitempty"`
  52. Mobile *string `protobuf:"bytes,4,opt,name=mobile" json:"mobile,omitempty"`
  53. Email *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"`
  54. Status *string `protobuf:"bytes,6,opt,name=status" json:"status,omitempty"`
  55. BusinessId *string `protobuf:"bytes,7,opt,name=business_id" json:"business_id,omitempty"`
  56. StoreId *string `protobuf:"bytes,8,opt,name=store_id" json:"store_id,omitempty"`
  57. FansTo *string `protobuf:"bytes,9,opt,name=fans_to" json:"fans_to,omitempty"`
  58. IsVip *string `protobuf:"bytes,10,opt,name=is_vip" json:"is_vip,omitempty"`
  59. Usercode *string `protobuf:"bytes,11,opt,name=usercode" json:"usercode,omitempty"`
  60. GroupId *string `protobuf:"bytes,12,opt,name=group_id" json:"group_id,omitempty"`
  61. XXX_unrecognized []byte `json:"-"`
  62. }
  63. func (m *UserResponse) Reset() { *m = UserResponse{} }
  64. func (m *UserResponse) String() string { return proto.CompactTextString(m) }
  65. func (*UserResponse) ProtoMessage() {}
  66. func (m *UserResponse) GetUserId() string {
  67. if m != nil && m.UserId != nil {
  68. return *m.UserId
  69. }
  70. return ""
  71. }
  72. func (m *UserResponse) GetUsername() string {
  73. if m != nil && m.Username != nil {
  74. return *m.Username
  75. }
  76. return ""
  77. }
  78. func (m *UserResponse) GetNickname() string {
  79. if m != nil && m.Nickname != nil {
  80. return *m.Nickname
  81. }
  82. return ""
  83. }
  84. func (m *UserResponse) GetMobile() string {
  85. if m != nil && m.Mobile != nil {
  86. return *m.Mobile
  87. }
  88. return ""
  89. }
  90. func (m *UserResponse) GetEmail() string {
  91. if m != nil && m.Email != nil {
  92. return *m.Email
  93. }
  94. return ""
  95. }
  96. func (m *UserResponse) GetStatus() string {
  97. if m != nil && m.Status != nil {
  98. return *m.Status
  99. }
  100. return ""
  101. }
  102. func (m *UserResponse) GetBusinessId() string {
  103. if m != nil && m.BusinessId != nil {
  104. return *m.BusinessId
  105. }
  106. return ""
  107. }
  108. func (m *UserResponse) GetStoreId() string {
  109. if m != nil && m.StoreId != nil {
  110. return *m.StoreId
  111. }
  112. return ""
  113. }
  114. func (m *UserResponse) GetFansTo() string {
  115. if m != nil && m.FansTo != nil {
  116. return *m.FansTo
  117. }
  118. return ""
  119. }
  120. func (m *UserResponse) GetIsVip() string {
  121. if m != nil && m.IsVip != nil {
  122. return *m.IsVip
  123. }
  124. return ""
  125. }
  126. func (m *UserResponse) GetUsercode() string {
  127. if m != nil && m.Usercode != nil {
  128. return *m.Usercode
  129. }
  130. return ""
  131. }
  132. func (m *UserResponse) GetGroupId() string {
  133. if m != nil && m.GroupId != nil {
  134. return *m.GroupId
  135. }
  136. return ""
  137. }
  138. // 用户登录请求结构
  139. type LoginRequest struct {
  140. Dbname *string `protobuf:"bytes,1,opt,name=dbname" json:"dbname,omitempty"`
  141. Account *string `protobuf:"bytes,2,opt,name=account" json:"account,omitempty"`
  142. Password *string `protobuf:"bytes,3,opt,name=password" json:"password,omitempty"`
  143. XXX_unrecognized []byte `json:"-"`
  144. }
  145. func (m *LoginRequest) Reset() { *m = LoginRequest{} }
  146. func (m *LoginRequest) String() string { return proto.CompactTextString(m) }
  147. func (*LoginRequest) ProtoMessage() {}
  148. func (m *LoginRequest) GetDbname() string {
  149. if m != nil && m.Dbname != nil {
  150. return *m.Dbname
  151. }
  152. return ""
  153. }
  154. func (m *LoginRequest) GetAccount() string {
  155. if m != nil && m.Account != nil {
  156. return *m.Account
  157. }
  158. return ""
  159. }
  160. func (m *LoginRequest) GetPassword() string {
  161. if m != nil && m.Password != nil {
  162. return *m.Password
  163. }
  164. return ""
  165. }
  166. // 使用token查询用户信息响应结构
  167. type LoginResponse struct {
  168. UserId *string `protobuf:"bytes,1,opt,name=user_id" json:"user_id,omitempty"`
  169. Username *string `protobuf:"bytes,2,opt,name=username" json:"username,omitempty"`
  170. Nickname *string `protobuf:"bytes,3,opt,name=nickname" json:"nickname,omitempty"`
  171. Mobile *string `protobuf:"bytes,4,opt,name=mobile" json:"mobile,omitempty"`
  172. Email *string `protobuf:"bytes,5,opt,name=email" json:"email,omitempty"`
  173. Status *string `protobuf:"bytes,6,opt,name=status" json:"status,omitempty"`
  174. BusinessId *string `protobuf:"bytes,7,opt,name=business_id" json:"business_id,omitempty"`
  175. StoreId *string `protobuf:"bytes,8,opt,name=store_id" json:"store_id,omitempty"`
  176. FansTo *string `protobuf:"bytes,9,opt,name=fans_to" json:"fans_to,omitempty"`
  177. IsVip *string `protobuf:"bytes,10,opt,name=is_vip" json:"is_vip,omitempty"`
  178. Token *string `protobuf:"bytes,11,opt,name=token" json:"token,omitempty"`
  179. Usercode *string `protobuf:"bytes,12,opt,name=usercode" json:"usercode,omitempty"`
  180. GroupId *string `protobuf:"bytes,13,opt,name=group_id" json:"group_id,omitempty"`
  181. XXX_unrecognized []byte `json:"-"`
  182. }
  183. func (m *LoginResponse) Reset() { *m = LoginResponse{} }
  184. func (m *LoginResponse) String() string { return proto.CompactTextString(m) }
  185. func (*LoginResponse) ProtoMessage() {}
  186. func (m *LoginResponse) GetUserId() string {
  187. if m != nil && m.UserId != nil {
  188. return *m.UserId
  189. }
  190. return ""
  191. }
  192. func (m *LoginResponse) GetUsername() string {
  193. if m != nil && m.Username != nil {
  194. return *m.Username
  195. }
  196. return ""
  197. }
  198. func (m *LoginResponse) GetNickname() string {
  199. if m != nil && m.Nickname != nil {
  200. return *m.Nickname
  201. }
  202. return ""
  203. }
  204. func (m *LoginResponse) GetMobile() string {
  205. if m != nil && m.Mobile != nil {
  206. return *m.Mobile
  207. }
  208. return ""
  209. }
  210. func (m *LoginResponse) GetEmail() string {
  211. if m != nil && m.Email != nil {
  212. return *m.Email
  213. }
  214. return ""
  215. }
  216. func (m *LoginResponse) GetStatus() string {
  217. if m != nil && m.Status != nil {
  218. return *m.Status
  219. }
  220. return ""
  221. }
  222. func (m *LoginResponse) GetBusinessId() string {
  223. if m != nil && m.BusinessId != nil {
  224. return *m.BusinessId
  225. }
  226. return ""
  227. }
  228. func (m *LoginResponse) GetStoreId() string {
  229. if m != nil && m.StoreId != nil {
  230. return *m.StoreId
  231. }
  232. return ""
  233. }
  234. func (m *LoginResponse) GetFansTo() string {
  235. if m != nil && m.FansTo != nil {
  236. return *m.FansTo
  237. }
  238. return ""
  239. }
  240. func (m *LoginResponse) GetIsVip() string {
  241. if m != nil && m.IsVip != nil {
  242. return *m.IsVip
  243. }
  244. return ""
  245. }
  246. func (m *LoginResponse) GetToken() string {
  247. if m != nil && m.Token != nil {
  248. return *m.Token
  249. }
  250. return ""
  251. }
  252. func (m *LoginResponse) GetUsercode() string {
  253. if m != nil && m.Usercode != nil {
  254. return *m.Usercode
  255. }
  256. return ""
  257. }
  258. func (m *LoginResponse) GetGroupId() string {
  259. if m != nil && m.GroupId != nil {
  260. return *m.GroupId
  261. }
  262. return ""
  263. }
  264. func init() {
  265. }
  266. type UserService interface {
  267. GetByToken(in *UserRequest, out *UserResponse) error
  268. Login(in *LoginRequest, out *LoginResponse) error
  269. }
  270. // AcceptUserServiceClient accepts connections on the listener and serves requests
  271. // for each incoming connection. Accept blocks; the caller typically
  272. // invokes it in a go statement.
  273. func AcceptUserServiceClient(lis net.Listener, x UserService) {
  274. srv := rpc.NewServer()
  275. if err := srv.RegisterName("UserService", x); err != nil {
  276. log.Fatal(err)
  277. }
  278. for {
  279. conn, err := lis.Accept()
  280. if err != nil {
  281. log.Fatalf("lis.Accept(): %v\n", err)
  282. }
  283. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  284. }
  285. }
  286. // RegisterUserService publish the given UserService implementation on the server.
  287. func RegisterUserService(srv *rpc.Server, x UserService) error {
  288. if err := srv.RegisterName("UserService", x); err != nil {
  289. return err
  290. }
  291. return nil
  292. }
  293. // NewUserServiceServer returns a new UserService Server.
  294. func NewUserServiceServer(x UserService) *rpc.Server {
  295. srv := rpc.NewServer()
  296. if err := srv.RegisterName("UserService", x); err != nil {
  297. log.Fatal(err)
  298. }
  299. return srv
  300. }
  301. // ListenAndServeUserService listen announces on the local network address laddr
  302. // and serves the given UserService implementation.
  303. func ListenAndServeUserService(network, addr string, x UserService) error {
  304. lis, err := net.Listen(network, addr)
  305. if err != nil {
  306. return err
  307. }
  308. defer lis.Close()
  309. srv := rpc.NewServer()
  310. if err := srv.RegisterName("UserService", x); err != nil {
  311. return err
  312. }
  313. for {
  314. conn, err := lis.Accept()
  315. if err != nil {
  316. log.Fatalf("lis.Accept(): %v\n", err)
  317. }
  318. go srv.ServeCodec(protorpc.NewServerCodec(conn))
  319. }
  320. }
  321. type UserServiceClient struct {
  322. *rpc.Client
  323. }
  324. // NewUserServiceClient returns a UserService rpc.Client and stub to handle
  325. // requests to the set of UserService at the other end of the connection.
  326. func NewUserServiceClient(conn io.ReadWriteCloser) (*UserServiceClient, *rpc.Client) {
  327. c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
  328. return &UserServiceClient{c}, c
  329. }
  330. func (c *UserServiceClient) GetByToken(in *UserRequest, out *UserResponse) error {
  331. return c.Call("UserService.GetByToken", in, out)
  332. }
  333. func (c *UserServiceClient) Login(in *LoginRequest, out *LoginResponse) error {
  334. return c.Call("UserService.Login", in, out)
  335. }
  336. // DialUserService connects to an UserService at the specified network address.
  337. func DialUserService(network, addr string) (*UserServiceClient, *rpc.Client, error) {
  338. c, err := protorpc.Dial(network, addr)
  339. if err != nil {
  340. return nil, nil, err
  341. }
  342. return &UserServiceClient{c}, c, nil
  343. }
  344. // DialUserServiceTimeout connects to an UserService at the specified network address.
  345. func DialUserServiceTimeout(network, addr string,
  346. timeout time.Duration) (*UserServiceClient, *rpc.Client, error) {
  347. c, err := protorpc.DialTimeout(network, addr, timeout)
  348. if err != nil {
  349. return nil, nil, err
  350. }
  351. return &UserServiceClient{c}, c, nil
  352. }