func NewRouter(cfg *RouterConfig, rs *redis_store.RedisStore) *Router { return &Router{ cfg: cfg, msgServerClientMap: make(map[string]*libnet.Session), sessionCache: redis_store.NewSessionCache(rs), topicCache: redis_store.NewTopicCache(rs), mongoStore: mongo_store.NewMongoStore(cfg.Mongo.Addr, cfg.Mongo.Port, cfg.Mongo.User, cfg.Mongo.Password), topicServerMap: make(map[string]string), } }
func NewGateway(cfg *GatewayConfig, rs *redis_store.RedisStore) *Gateway { return &Gateway{ cfg: cfg, msgServerClientMap: make(map[string]*libnet.Session), msgServerNumMap: make(map[string]uint64), server: new(libnet.Server), sessionCache: redis_store.NewSessionCache(rs), mongoStore: mongo_store.NewMongoStore(cfg.Mongo.Addr, cfg.Mongo.Port, cfg.Mongo.User, cfg.Mongo.Password), } }
func NewMsgServer(cfg *MsgServerConfig, rs *redis_store.RedisStore) *MsgServer { return &MsgServer{ cfg: cfg, sessions: make(base.SessionMap), channels: make(base.ChannelMap), topics: make(protocol.TopicMap), server: new(libnet.Server), sessionCache: redis_store.NewSessionCache(rs), topicCache: redis_store.NewTopicCache(rs), offlineMsgCache: redis_store.NewOfflineMsgCache(rs), mongoStore: mongo_store.NewMongoStore(cfg.Mongo.Addr, cfg.Mongo.Port, cfg.Mongo.User, cfg.Mongo.Password), p2pAckStatus: make(base.AckMap), } }
func NewMonitor(cfg *MonitorConfig) *Monitor { return &Monitor{ cfg: cfg, msgServerClientMap: make(map[string]*libnet.Session), sessionStore: redis_store.NewSessionCache(redis_store.NewRedisStore(&redis_store.RedisStoreOptions{ Network: "tcp", Address: cfg.Redis.Addr + cfg.Redis.Port, ConnectTimeout: time.Duration(cfg.Redis.ConnectTimeout) * time.Millisecond, ReadTimeout: time.Duration(cfg.Redis.ReadTimeout) * time.Millisecond, WriteTimeout: time.Duration(cfg.Redis.WriteTimeout) * time.Millisecond, Database: 1, KeyPrefix: base.COMM_PREFIX, })), topicServerMap: make(map[string]string), } }
func NewManager(cfg *ManagerConfig) *Manager { return &Manager{ cfg: cfg, sessionCache: redis_store.NewSessionCache(redis_store.NewRedisStore(&redis_store.RedisStoreOptions{ Network: "tcp", Address: cfg.Redis.Addr + cfg.Redis.Port, ConnectTimeout: time.Duration(cfg.Redis.ConnectTimeout) * time.Millisecond, ReadTimeout: time.Duration(cfg.Redis.ReadTimeout) * time.Millisecond, WriteTimeout: time.Duration(cfg.Redis.WriteTimeout) * time.Millisecond, Database: 1, KeyPrefix: base.COMM_PREFIX, })), topicCache: redis_store.NewTopicCache(redis_store.NewRedisStore(&redis_store.RedisStoreOptions{ Network: "tcp", Address: cfg.Redis.Addr + cfg.Redis.Port, ConnectTimeout: time.Duration(cfg.Redis.ConnectTimeout) * time.Millisecond, ReadTimeout: time.Duration(cfg.Redis.ReadTimeout) * time.Millisecond, WriteTimeout: time.Duration(cfg.Redis.WriteTimeout) * time.Millisecond, Database: 1, KeyPrefix: base.COMM_PREFIX, })), mongoStore: mongo_store.NewMongoStore(cfg.Mongo.Addr, cfg.Mongo.Port, cfg.Mongo.User, cfg.Mongo.Password), } }