duanjue7745 2018-08-28 00:41
浏览 76
已采纳

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

[UPDATE]: Current redis sends every published message to every node in entire cluster:

/* -----------------------------------------------------------------------------
 * 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);
}

This is original text of question, which is not correct:

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?

  • 写回答

1条回答 默认 最新

  • dongxianghuan3587 2018-08-28 09:36
    关注

    PubSub channels in the Redis cluster are shared among all nodes - messages are passed via the internal bus so you don't need a special client and/or logic.

    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.

    Source: Redis Cluster Specification

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?