-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Sentinel pool slave #103
Sentinel pool slave #103
Conversation
👍 |
today ? |
def redisConnection: ActorRef = masterClient.redisConnection | ||
|
||
override def send[T](redisCommand: RedisCommand[_ <: RedisReply, T]): Future[T] = { | ||
if (redisCommand.isMasterOnly || slavesClients.getConnectionsActive.isEmpty) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getConnectionsActive
is expensive (even more for just a isEmpty)
I think we can cache the result of getConnectionsActive or something like that
I also think most of the time we only need 1 active connection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will replace by this
if (redisCommand.isMasterOnly || slavesClients.redisServers.exists(_.active.single.get)) {
masterClient.send(redisCommand)
} else {
slavesClients.send(redisCommand)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think we can be even smarter trying to mix in the getNextConnection
in RoundRobinPoolRequest
The ideal would be to find the next
active connection in the RoundRobinPoolRequest
If we find it, then we have a slave where we can send the command. Otherwise we can send the command to the master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it exactly what happens: slavesClients is a RoundRobinPoolRequest
Can you put the return for all the function even |
lazy val redisMasterSlavesPool = | ||
SentinelMonitoredRedisClientMasterSlaves( master = masterName, | ||
sentinels = sentinelPorts.map((redisHost, _))) | ||
"sentienl slave pool" should { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sentienl 😜
Hey, you are on the good path 😃 |
87455b9
to
c7de528
Compare
c7de528
to
762ecad
Compare
@@ -35,13 +30,12 @@ abstract class RedisClientPoolLike(system: ActorRefFactory) extends RoundRobinPo | |||
} | |||
} | |||
|
|||
val redisConnectionRef: Ref[Seq[ActorRef]] = Ref(getConnectionsActive) | |||
lazy val redisConnectionRef: Ref[Seq[ActorRef]] = Ref(getConnectionsActive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val redisConnectionRef: Ref[Seq[ActorRef]] = Ref(Seq.empty)
When we start we have no slave
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I was wrong,
but can you remove the lazy
In the tests there are a lot of |
I finally find a bug on mutable pool |
thanks |
sentinel manage a slave pool: