123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package rpc
- import (
- "go-common/app/service/main/rank/conf"
- "go-common/app/service/main/rank/model"
- "go-common/app/service/main/rank/service"
- "go-common/library/net/rpc"
- "go-common/library/net/rpc/context"
- )
- // RPC favorite rpc.
- type RPC struct {
- c *conf.Config
- s *service.Service
- }
- // New init rpc.
- func New(c *conf.Config, s *service.Service) (svr *rpc.Server) {
- r := &RPC{
- c: c,
- s: s,
- }
- svr = rpc.NewServer(c.RPCServer)
- if err := svr.Register(r); err != nil {
- panic(err)
- }
- return
- }
- // Ping check connection success.
- func (r *RPC) Ping(c context.Context, arg *struct{}, res *struct{}) (err error) {
- return
- }
- // Mget .
- func (r *RPC) Mget(c context.Context, a *model.MgetReq, res *model.MgetResp) (err error) {
- var v *model.MgetResp
- if v, err = r.s.Mget(c, a); err == nil {
- *res = *v
- }
- return
- }
- // Sort .
- func (r *RPC) Sort(c context.Context, a *model.SortReq, res *model.SortResp) (err error) {
- var v *model.SortResp
- if v, err = r.s.Sort(c, a); err == nil {
- *res = *v
- }
- return
- }
- // Group .
- func (r *RPC) Group(c context.Context, a *model.GroupReq, res *model.GroupResp) (err error) {
- var v *model.GroupResp
- if v, err = r.s.Group(c, a); err == nil {
- *res = *v
- }
- return
- }
|