处理需要来自另一个有界上下文的数据的用例的良好实践 [英] Good practice to handle a use case requiring data from another bounded context

查看:76
本文介绍了处理需要来自另一个有界上下文的数据的用例的良好实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的软件是一种社交网络,除其他功能外,会员还可以安排他们之间的一些会议.

My software is a kind of social network where members can, among other features, schedule some meetings between them.

我选择出现这三个有界上下文(DDD):

I chose to emerge those three bounded contexts (DDD):

  • IdentityAndAccessContext ,基本上用于处理用户身份验证/授权.
  • SocialContext ,与会员以及与会员有关的所有社交信息;他们的兴趣等等,就像一个经典的社交网络.
  • MeetingsContext ,用于处理某些成员之间的会议.我们正在谈论以创造者/参与者/参与者等身份转换的价值对象.
  • IdentityAndAccessContext, basically dealing with user authentication/authorisation.
  • SocialContext, dealing with Members and all social information about them; their interests etc., akin a classical social network.
  • MeetingsContext, dealing with meetings between some members. We're talking about translated Value Objects as Creators/Attendees/Participants etc.

基本上,在 MeetingsContext 中,会议的创建用例需要一个成员列表(以邀请其中的一些成员),基本上是通过Web表单,用户在该表单中选择一些成员,这些成员提出了一些有趣但又有趣的内容.轻松的社交信息.

Basically, in the MeetingsContext, the meeting's creation use case demands a list of members (in order to invite some of them), basically through a Web form where user selects some members presenting some interesting but light social information.

您可能会发现, SocialContext 显然是一种社交方式的成员数据主控.

As you may figure out, SocialContext is clearly the master of members data in a social way.

是否应该在 SocialContext 中创建一种 Open Host Service ,并返回用例的一些相关成员数据?

Should I create a kind of Open Host Service in the SocialContext returning some relevant members data for the use case?

它将直接由 MeetingsContext (REST协议)使用,如果需要,可以通过反腐败层使用.

It would be consumed by MeetingsContext directly (REST protocol), maybe through an Anti-Corruption Layer if needed.

还是我应该在 MeetingsContext 中缓存甚至复制相关成员的数据,以改善其自包含的方面?

Or should I rather cache or even maybe duplicate relevant member's data in the MeetingsContext to improve it's self-contained aspect?

使用缓存解决方案,缓存将以最终的一致性方式进行同步.

With the caching solution, the cache would be sync in an eventual consistency manner.

在这种情况下,什么是好的做法?

What is a good practice in this case?

推荐答案

在这些情况下,复合UI是一个不错的选择.您的会议上下文只需要知道会员ID即可,也许不需要了解有关其通讯偏好的一些信息即可建立会议.

Composite UI is a good choice in these situations. Your meeting contexts does not need to know anything more than member id and perhaps some information about their communication preferences in order to establish a meeting.

撰写与会者列表不需要参加会议上下文.该UI元素很可能来自社交上下文UI,然后在选择完成后将参与者ID列表发送到会议上下文.

Composing a list of participants does not require the meeting context involvement. This UI element can very well come from the social context UI and then send the list of participant ids to the meeting context, when selection is complete.

一般规则是,仅在屏幕上显示一些内容,以避免上下文之间的数据传输.负责任的环境应该这样做.

The general rule is to avoid data transmission between contexts just in sake of showing some stuff on the screen. The responsible context should be doing that.

以下是一些参考资料:

  • The secret of better UI composition by Mauro Servienti
  • Composite UIs for Microservices - A Primer by Jimmy Bogard

这篇关于处理需要来自另一个有界上下文的数据的用例的良好实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆