简体   繁体   English

如何按节奏动态创建工作流

[英]How to create workflows dynamically in cadence

Each workflow should be implemented in a separate workflow class?每个工作流都应该在单独的工作流 class 中实现?

Is it recommended to implement a generic workflow class where we will call activities and fire timers using the argument which passed to the workflow?是否建议实施通用工作流 class ,我们将使用传递给工作流的参数调用活动和触发计时器?

In our use case, we will be creating workflows from UI and it will be created by the end-user.在我们的用例中,我们将从 UI 创建工作流,它将由最终用户创建。 So we cannot define our workflows initially.因此,我们最初无法定义我们的工作流程。

Is it recommended approach?是推荐的方法吗?

It's not recommended.不建议这样做。

Even though it is still possible if you have to create and register workflow class dynamically using anonymous class.即使您必须使用匿名 class 动态创建和注册工作流 class 仍然是可能的。 But it will be very difficult to maintain and debug.但是维护和调试会非常困难。 For example, registering a workflow requires a unique workflow type name, and also it's required to register back the exact same workflow after worker restarts.例如,注册工作流需要唯一的工作流类型名称,并且还需要在工作人员重新启动后重新注册完全相同的工作流。 Etc.等等。

What you describe is very common use cases in Cadence.您描述的是 Cadence 中非常常见的用例。 And this is also the power of Cadence over other DSL workflow engine.这也是 Cadence 优于其他 DSL 工作流引擎的强大之处。 What you need to do is implement a workflow in a way that takes in dynamic input parameters, and decides the behavior on the input.您需要做的是以接受动态输入参数并决定输入行为的方式实现工作流。 It's essentially exactly same as what you want to do with dynamic workflow class.它与您想要对动态工作流 class 执行的操作基本完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM