事件分组的设计模式

发布于 2024-12-27 07:39:06 字数 387 浏览 2 评论 0原文

我想用事件驱动(或消息驱动)架构来实现现有模型。 一些实体需要触发事件来更新其他实体。

B 类实体依赖于 A 类实体。 因此,当 A 实体发生变化时,我将触发一个事件来让一些 B 实体更新 (多个 A 实体“链接”到一个 B 实体)。

在某些情况下,我需要更新所有 A 实体。这将生成事件。 但大多数这些事件将是“redondant”,因为我将更新每个 B 实体 几次。 我想“分组”或“延迟”这些事件

对于我的用例来说,有用的设计模式是什么? 我需要对待处理事件进行分组吗? 我需要延迟事件吗? 我需要使事件失效吗?基于时间戳 ?

我正在使用 Python,但任何语言的示例都会受到赞赏。

I would to implement a existing model with an event-driven (or message-driven) architecture.
Some entities need to fire events to update other entities.

For entities of class B depends on entities of class A.
So when an A entity is changing, I will fire an event to let some B entities to update
(several A entities are "linked" to one B entity).

In some case, I need to update all A entities. This will generate events.
But most of those events will be "redondant" because I will update each B entity
several times. I would like to "group" or "delay" those events.

What are the usefull design patterns for my use case ?
Do I need grouping pending events ?
Do I need delaying events ?
Do I need event invalidation ? based on time-stamp ?

I am using Python but examples in any langages will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文