Skip to content

Commit

Permalink
Add password and db to SentinelMonitoredRedisClientMasterSlaves
Browse files Browse the repository at this point in the history
  • Loading branch information
DJFliX committed May 29, 2017
1 parent 55573df commit 6c77619
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/scala/redis/RedisPool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,33 +177,33 @@ case class RedisClientMasterSlaves(master: RedisServer,


case class SentinelMonitoredRedisClientMasterSlaves(
sentinels: Seq[(String, Int)] = Seq(("localhost", 26379)), master: String)
sentinels: Seq[(String, Int)] = Seq(("localhost", 26379)), master: String, password: Option[String] = None, db: Option[Int] = None)
(implicit _system: ActorSystem, redisDispatcher: RedisDispatcher = Redis.dispatcher)
extends SentinelMonitored(_system, redisDispatcher) with ActorRequest with RedisCommands with Transactions {

val masterClient: RedisClient = withMasterAddr(
(ip, port) => {
new RedisClient(ip, port, name = "SMRedisClient")
new RedisClient(ip, port, name = "SMRedisClient", password = password, db = db)
})

val slavesClients: RedisClientMutablePool = withSlavesAddr(
slavesHostPort => {
val slaves = slavesHostPort.map {
case (ip, port) =>
new RedisServer(ip, port)
new RedisServer(ip, port, password = password, db = db)
}
new RedisClientMutablePool(slaves, name = "SMRedisClient")
})


val onNewSlave = (ip: String, port: Int) => {
log.info(s"onNewSlave $ip:$port")
slavesClients.addServer(RedisServer(ip, port))
slavesClients.addServer(RedisServer(ip, port, password = password, db = db))
}

val onSlaveDown = (ip: String, port: Int) => {
log.info(s"onSlaveDown $ip:$port")
slavesClients.removeServer(RedisServer(ip, port))
slavesClients.removeServer(RedisServer(ip, port, password = password, db = db))
}

val onMasterChange = (ip: String, port: Int) => {
Expand Down

0 comments on commit 6c77619

Please sign in to comment.