|
|
@ -35,33 +35,48 @@ type dataServant struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewDataService() (core.DataService, core.VersionInfo) {
|
|
|
|
func NewDataService() (core.DataService, core.VersionInfo) {
|
|
|
|
// initialize CacheIndex if needed
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
c core.CacheIndexService
|
|
|
|
v core.VersionInfo
|
|
|
|
v core.VersionInfo
|
|
|
|
cis core.CacheIndexService
|
|
|
|
|
|
|
|
ips core.IndexPostsService
|
|
|
|
)
|
|
|
|
)
|
|
|
|
db := pgxDB()
|
|
|
|
db := pgxDB()
|
|
|
|
pvs := security.NewPhoneVerifyService()
|
|
|
|
pvs := security.NewPhoneVerifyService()
|
|
|
|
|
|
|
|
ams := NewAuthorizationManageService()
|
|
|
|
|
|
|
|
ths := newTweetHelpService(db)
|
|
|
|
|
|
|
|
|
|
|
|
i := newIndexPostsService(db)
|
|
|
|
// initialize core.IndexPostsService
|
|
|
|
|
|
|
|
if cfg.If("Friendship") {
|
|
|
|
|
|
|
|
ips = newFriendIndexService(db, ams, ths)
|
|
|
|
|
|
|
|
} else if cfg.If("Followship") {
|
|
|
|
|
|
|
|
ips = newFollowIndexService(db, ths)
|
|
|
|
|
|
|
|
} else if cfg.If("Lightship") {
|
|
|
|
|
|
|
|
ips = newLightIndexService(db, ths)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// default use lightship post index service
|
|
|
|
|
|
|
|
ips = newLightIndexService(db, ths)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// initialize core.CacheIndexService
|
|
|
|
if cfg.If("SimpleCacheIndex") {
|
|
|
|
if cfg.If("SimpleCacheIndex") {
|
|
|
|
i = newSimpleIndexPostsService(db)
|
|
|
|
// simpleCache use special post index service
|
|
|
|
c, v = cache.NewSimpleCacheIndexService(i)
|
|
|
|
ips = newSimpleIndexPostsService(db, ths)
|
|
|
|
|
|
|
|
cis, v = cache.NewSimpleCacheIndexService(ips)
|
|
|
|
} else if cfg.If("BigCacheIndex") {
|
|
|
|
} else if cfg.If("BigCacheIndex") {
|
|
|
|
a := newAuthorizationManageService(db)
|
|
|
|
// TODO: make cache index post in different scence like friendship/followship/lightship
|
|
|
|
c, v = cache.NewBigCacheIndexService(i, a)
|
|
|
|
cis, v = cache.NewBigCacheIndexService(ips, ams)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
c, v = cache.NewNoneCacheIndexService(i)
|
|
|
|
cis, v = cache.NewNoneCacheIndexService(ips)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logrus.Infof("use %s as cache index service by version: %s", v.Name(), v.Version())
|
|
|
|
logrus.Infof("use %s as cache index service by version: %s", v.Name(), v.Version())
|
|
|
|
|
|
|
|
|
|
|
|
ds := &dataServant{
|
|
|
|
ds := &dataServant{
|
|
|
|
IndexPostsService: c,
|
|
|
|
IndexPostsService: cis,
|
|
|
|
WalletService: newWalletService(db),
|
|
|
|
WalletService: newWalletService(db),
|
|
|
|
MessageService: newMessageService(db),
|
|
|
|
MessageService: newMessageService(db),
|
|
|
|
TopicService: newTopicService(db),
|
|
|
|
TopicService: newTopicService(db),
|
|
|
|
TweetService: newTweetService(db),
|
|
|
|
TweetService: newTweetService(db),
|
|
|
|
TweetManageService: newTweetManageService(db, c),
|
|
|
|
TweetManageService: newTweetManageService(db, cis),
|
|
|
|
TweetHelpService: newTweetHelpService(db),
|
|
|
|
TweetHelpService: newTweetHelpService(db),
|
|
|
|
CommentService: newCommentService(db),
|
|
|
|
CommentService: newCommentService(db),
|
|
|
|
CommentManageService: newCommentManageService(db),
|
|
|
|
CommentManageService: newCommentManageService(db),
|
|
|
|