fix: msg cache timeout.

pull/2148/head
Gordon 1 year ago
parent 51bb55585f
commit 7969f56d44

@ -1,5 +1,3 @@
prometheus: prometheus:
enable: true enable: true
ports: [ 20108, 20109, 20110, 20111 ] ports: [ 20108, 20109, 20110, 20111 ]
msgCacheTimeout: 86400

@ -88,7 +88,7 @@ func Start(ctx context.Context, index int, config *Config) error {
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin"))) grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
//todo MsgCacheTimeout //todo MsgCacheTimeout
msgModel := cache.NewMsgCache(rdb, 86400, config.RedisConfig.EnablePipeline) msgModel := cache.NewMsgCache(rdb, config.RedisConfig.EnablePipeline)
seqModel := cache.NewSeqCache(rdb) seqModel := cache.NewSeqCache(rdb)
msgDocModel, err := mgo.NewMsgMongo(mgocli.GetDB()) msgDocModel, err := mgo.NewMsgMongo(mgocli.GetDB())
if err != nil { if err != nil {

@ -86,7 +86,7 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg
return err return err
} }
//todo MsgCacheTimeout //todo MsgCacheTimeout
msgModel := cache.NewMsgCache(rdb, 86400, config.RedisConfig.EnablePipeline) msgModel := cache.NewMsgCache(rdb, config.RedisConfig.EnablePipeline)
seqModel := cache.NewSeqCache(rdb) seqModel := cache.NewSeqCache(rdb)
conversationClient := rpcclient.NewConversationRpcClient(client, config.Share.RpcRegisterName.Conversation) conversationClient := rpcclient.NewConversationRpcClient(client, config.Share.RpcRegisterName.Conversation)
userRpcClient := rpcclient.NewUserRpcClient(client, config.Share.RpcRegisterName.User, config.Share.IMAdminUserID) userRpcClient := rpcclient.NewUserRpcClient(client, config.Share.RpcRegisterName.User, config.Share.IMAdminUserID)

@ -185,8 +185,7 @@ type MsgGateway struct {
} }
type MsgTransfer struct { type MsgTransfer struct {
Prometheus Prometheus `mapstructure:"prometheus"` Prometheus Prometheus `mapstructure:"prometheus"`
MsgCacheTimeout int `mapstructure:"msgCacheTimeout"`
} }
type Push struct { type Push struct {

@ -31,6 +31,8 @@ import (
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
) )
const msgCacheTimeout = 86400
const ( const (
maxSeq = "MAX_SEQ:" maxSeq = "MAX_SEQ:"
minSeq = "MIN_SEQ:" minSeq = "MIN_SEQ:"
@ -82,7 +84,7 @@ type MsgCache interface {
// return &msgCache{rdb: client, msgCacheTimeout: msgCacheTimeout, redisConf: redisConf} // return &msgCache{rdb: client, msgCacheTimeout: msgCacheTimeout, redisConf: redisConf}
//} //}
func NewMsgCache(client redis.UniversalClient, msgCacheTimeout time.Duration, redisEnablePipeline bool) MsgCache { func NewMsgCache(client redis.UniversalClient, redisEnablePipeline bool) MsgCache {
return &msgCache{rdb: client, msgCacheTimeout: msgCacheTimeout, redisEnablePipeline: redisEnablePipeline} return &msgCache{rdb: client, msgCacheTimeout: msgCacheTimeout, redisEnablePipeline: redisEnablePipeline}
} }

Loading…
Cancel
Save