-
Notifications
You must be signed in to change notification settings - Fork 0
/
dao.go
71 lines (59 loc) · 1.75 KB
/
dao.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package rpc
import (
"context"
"go-common/app/admin/main/aegis/conf"
account "go-common/app/service/main/account/api"
relmod "go-common/app/service/main/relation/model"
relrpc "go-common/app/service/main/relation/rpc/client"
uprpc "go-common/app/service/main/up/api/v1"
"google.golang.org/grpc"
)
// Dao dao
type Dao struct {
c *conf.Config
//gorpc
relRPC RelationRPC
//grpc
AccountClient AccRPC
UpClient UpRPC
}
// New init mysql db
func New(c *conf.Config) (dao *Dao) {
dao = &Dao{
c: c,
}
if c.Debug != "local" {
dao.relRPC = relrpc.New(c.RPC.Rel)
var err error
if dao.AccountClient, err = account.NewClient(c.GRPC.AccRPC); err != nil {
panic(err)
}
if dao.UpClient, err = uprpc.NewClient(c.GRPC.UpRPC); err != nil {
panic(err)
}
}
return
}
// Close close the resource.
func (d *Dao) Close() {
}
// Ping dao ping
func (d *Dao) Ping(c context.Context) error {
return nil
}
//RelationRPC .
type RelationRPC interface {
Stats(c context.Context, arg *relmod.ArgMids) (res map[int64]*relmod.Stat, err error)
}
//AccRPC .
type AccRPC interface {
Info3(ctx context.Context, in *account.MidReq, opts ...grpc.CallOption) (*account.InfoReply, error)
Cards3(ctx context.Context, in *account.MidsReq, opts ...grpc.CallOption) (*account.CardsReply, error)
ProfileWithStat3(ctx context.Context, in *account.MidReq, opts ...grpc.CallOption) (*account.ProfileStatReply, error)
}
//UpRPC .
type UpRPC interface {
UpSpecial(ctx context.Context, in *uprpc.UpSpecialReq, opts ...grpc.CallOption) (*uprpc.UpSpecialReply, error)
UpsSpecial(ctx context.Context, in *uprpc.UpsSpecialReq, opts ...grpc.CallOption) (*uprpc.UpsSpecialReply, error)
UpGroups(ctx context.Context, in *uprpc.NoArgReq, opts ...grpc.CallOption) (*uprpc.UpGroupsReply, error)
}