Py学习  »  Redis

是否有一个golang redis客户端自动检测pubsub的新碎片?

Andrew Arrow • 4 年前 • 606 次点击  

[更新]:当前redis将每个已发布的消息发送到整个集群中的每个节点:

/* -----------------------------------------------------------------------------
 * CLUSTER Pub/Sub support
 *
 * For now we do very little, just propagating PUBLISH messages across the whole
 * cluster. In the future we'll try to get smarter and avoiding propagating those
 * messages to hosts without receives for a given channel.
 * -------------------------------------------------------------------------- */
void clusterPropagatePublish(robj *channel, robj *message) {
    clusterSendPublish(NULL, channel, message);
}

这是问题的原文,不正确:

据我所知,我需要:

  1. 给定一个通道,找到拥有散列槽的节点。

  2. 订阅该节点和cluster:slots以检测迁移。

  3. 在插槽迁移时,订阅新节点上的通道并保持旧连接打开。

  4. 将消息从旧连接转发到应用程序,直到它关闭并记住这些消息。

  5. 当迁移完成并且旧连接关闭时,从新连接转发消息,修剪记住的消息 从第一个连接开始。

golang redis客户端库中有没有这样做?我查过了 很多人觉得我需要自己不断地写这个逻辑 轮询 CLUSTER SLOTS 或者听一个公开的信息 当碎片增加或减少并移动我现有的pubsub时 从一个服务器到另一个服务器的脚本。

也就是说,有很多golang libs处理普通的get key和cluster 即使碎片的数量改变了。但是pubsub和cluster是 其他的事情对吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/37884
 
606 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Itamar Haber
Reply   •   1 楼
Itamar Haber    5 年前