假设在任何数据中心都有不同的网络分区(例如 DMZ 区域),因此某些主机集无法联系其他主机集。因此,如果我想将消息传播到任何数据中心中的所有主机,gossip/consul 是否适用于该用例?
对于上述问题,我想到的一种解决方案是:允许 DMZ 区域中的所有主机连接到领事服务器(仅限少数主机)。这就像一些主机集无法与其他主机集联系,但数据中心中的所有主机都可以与领事服务器对话。但我不确定,即使这样,任何消息都可以传播到数据中心的所有主机。
Gossip 仅用于 consul,而 consul 又仅用于服务注册、服务发现和与配置相关的键/值数据。
事件机制可能是您想要的,来自 Python 文档:
Event = <class 'consul.base.Consul.Event'>
The event command provides a mechanism to fire a custom user event to
an entire datacenter. These events are opaque to Consul, but they can
be used to build scripting infrastructure to do automated deploys,
restart services, or perform any other orchestration action.
Unlike most Consul data, which is replicated using consensus, event
data is purely peer-to-peer over gossip.
This means it is not persisted and does not have a total ordering. In
practice, this means you cannot rely on the order of message delivery.
An advantage however is that events can still be used even in the
absence of server nodes or during an outage.