我想设计一个完整的端到端工作流编排引擎。
它有以下要求
答案 0 :(得分:0)
Cadence 工作流程很容易支持所有 1-5。我不确定您所说的 Polling
是什么意思。如果您能提供更多详细信息,我会更新此答案以帮助您。
这是sample to execute activities in Leaner+parallel/batch+loop:
@Override
public long calculate(long a, long b, long c) {
LOGGER.info("workflow start...");
long result = 0;
// Async.invoke takes method reference and activity parameters and returns Promise.
Promise<Long> ab = Async.function(activities::multiple, a, b);
Promise<Long> ac = Async.function(activities::multiple, a, c);
Promise<Long> bc = Async.function(activities::multiple, b, c);
// Promise#get blocks until result is ready.
this.abPlusAcPlusBc = result = ab.get() + ac.get() + bc.get();
// waiting 30s for a human input to decide the factor N for g(n), based on a*b+a*c+b*c
// the waiting timer is durable, independent of workers' liveness
final boolean received = Workflow.await(Duration.ofMinutes(2), () -> this.factorForGn > 1);
if (!received) {
this.factorForGn = 10;
}
long fi_1 = 0; // f(0)
long fi_2 = 1; // f(1)
this.currentG = 1; // current g = f(0)*f(0) + f(1)*f(1)
long i = 2;
for (; i < this.factorForGn; i++) {
// get next fibonacci number
long fi = fi_1 + fi_2;
fi_2 = fi_1;
fi_1 = fi;
this.currentG += activities.multiple(fi, fi);
}
result += this.currentG;
return result;
}