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

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

概述[更新]:当前redis将每个已发布的消息发送到整个集群中的每个节点: /* ----------------------------------------------------------------------------- * CLUSTER Pub/Sub support * * For now we do very little, just propagating PUBLIS [更新]:当前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:

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

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

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

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

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

总结

以上是内存溢出为你收集整理的是否有一个golang redis客户端可以自动检测pubsub的新分片?全部内容,希望文章能够帮你解决是否有一个golang redis客户端可以自动检测pubsub的新分片?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1266357.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存