DDD/CQRS/ES 如何在领域层中建模 shell 命令?

DDD/CQRS/ES How to model a shell command in the domain layer?

我有一个域,我需要在其中从外部数据源导入和处理多个聚合,并通过 运行 对每个聚合执行 shell 命令。

假设一个 补丁 AR 表示需要在本地文件系统上应用的补丁。 Patch AR 是根据来自外部数据源的原语构建的,一旦导入,需要通过执行 shell 命令应用于文件系统。这里的问题是,我应该如何模拟通过 运行 和 shell 命令应用补丁的事实? Patch AR 是否可以提供依赖领域服务的方法,例如 apply(IPatcherService $patcherService),将在基础设施层实现?

Does the Patch AR can provides a method relying on a domain service

可以那样做,但通常我更愿意在应用层忽略这些细节。

领域层是簿记;它跟踪文件系统上已经发生的事情以及接下来应该发生的事情......但是实际与文件系统对话的代码在应用程序的某个地方。

回顾 Mark Seemann 的 Async Injection talk, or Cory Benfield's Building Protocol Libraries the Right Way

From my point of view, the fact to apply a patch of the filesystem is part of the domain model (Patching System), not just an implementation detail. Why ? because the result of the shell command will change state of the Patch (applied/unapplied). I want represent that fact in my model and that why I want add such interface. Now, I can be wrong somewhere

我不认为这会改变原则——您的域模型仍在记录发生的效果 "somewhere else"。事实上,您的其他地方恰好是 "the filesystem on disk" 并没有改变这一点。