预处理过程和后处理任务使用哪种设计模式
我正在开发一种迁移引擎,用于将数据从旧系统迁移到新系统。它分为3步。
- 首先从旧表中获取数据。
- 准备请求正文以通过 API
- 后处理步骤插入到新表中。
这里使用哪种设计模式?
我正在考虑使用构建器模式
在第二步中,我进行多个 API 调用以将数据插入新表中。这有一定的顺序。如果 API 调用在中间失败,则需要重做之前的所有 API 调用。一种回滚机制。我怎样才能做到这一点?
I am working on one migration engine to migrate data from older system to newer system. it is divided into 3 steps.
- first getting the data from older tables.
- prepare the request body to insert into new tables via APIs
- post processing steps.
Which design pattern to use here?
I was thinking of using builder pattern
In the second step where i am doing multiple API calls for inserting data into new tables. this has some order. If API call fail in between then need to redo all previous API calls. kind of rollbacking mechanism. How can i achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您可能希望在这里采用管道过滤器模式作为整体设计。您所描述的内容几乎此处描述 。
I think you might want to go for a Pipe-Filter Pattern here as an overall design. What you describe is pretty much described here.
在这里,您已经有了要执行的预定义和明确的步骤。在这种情况下,
模板设计模式
效果很好。调用步骤的顺序是固定的,每个步骤的职责可以分为单独的类,最后可以链接到模板管理类上。
请参阅此链接 - https://refactoring.guru/design-patterns/template-method
Here you already have pre-defined and definite steps to perform. In this case
template design pattern
works well.Sequence of calling steps are fixed and Responsibility of each steps can be seggregated into separate classes and finally can be linked on template management class.
Refer this link - https://refactoring.guru/design-patterns/template-method