加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-16 09:25:01 所属栏目:大数据 来源:网络整理
导读:[更新]:当前redis将每个已发布的消息发送到整个集群中的每个节点: /* ----------------------------------------------------------------------------- * CLUSTER Pub/Sub support * * For now we do very little,just propagating PUBLISH messages acro
[更新]:当前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);
}

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

As I understand it I need to:

  1. Given a channel,find the the node that owns the hash slot.

  2. Subscribe to that node and also to cluster:slots to detect migrations.

  3. Upon slot migration,subscribe to the channel on the new node and keep the old connection open.

  4. Forward messages to the application from the old connection until it closes and remember those messages.

  5. When migration is complete and the old connection closed,forward messages from the new connection,trimming the remembered messages
    from the first connection.

Do any of the golang redis client library do this? I’ve looked through
many and it feels like I need to write this logic myself,constantly
polling CLUSTER SLOTS or listening to a pubsub of that info to know
when shards increase or decrease and move my existing pubsub
scriptions from one server to another.

I.e. there lots of golang libs that handle normal GET key with cluster
even if the number of shards changes. But pubsub and cluster is a
whole other thing right?

解决方法

Redis集群中的PubSub通道在所有节点之间共享 – 消息通过内部总线传递,因此您不需要特殊的客户端和/或逻辑.

In a Redis Cluster clients can subscribe to every node,and can also publish to every other node. The cluster will make sure that published messages are forwarded as needed.

资料来源:Redis Cluster Specification

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读