mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 18:28:10 +01:00
Listen for new messages via keyspace notifications.
This commit is contained in:
committed by
Jon Chambers
parent
2c29f831e8
commit
8d3316ccd6
@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.textsecuregcm.redis.ClusterLuaScript;
|
||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||
import org.whispersystems.textsecuregcm.util.Constants;
|
||||
import org.whispersystems.textsecuregcm.util.RedisClusterUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
@@ -81,15 +82,9 @@ public class ClientPresenceManager extends RedisClusterPubSubAdapter<String, Str
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
RedisClusterUtil.assertKeyspaceNotificationsConfigured(presenceCluster, "K$");
|
||||
|
||||
presenceCluster.usePubSubConnection(connection -> {
|
||||
final String configuredKeyspaceNotifications = connection.sync().configGet("notify-keyspace-events").getOrDefault("notify-keyspace-events", "");
|
||||
|
||||
for (final char requiredNotificationType : new char[] {'K', '$'}) {
|
||||
if (configuredKeyspaceNotifications.indexOf(requiredNotificationType) == -1) {
|
||||
throw new IllegalStateException("Required keyspace notification type not configured. Need at least K$, but is actually: " + configuredKeyspaceNotifications);
|
||||
}
|
||||
}
|
||||
|
||||
connection.addListener(this);
|
||||
connection.getResources().eventBus().get()
|
||||
.filter(event -> event instanceof ClusterTopologyChangedEvent)
|
||||
|
||||
Reference in New Issue
Block a user