Closed hossam-nasr closed 9 months ago
Just to confirm, in this example:
const flakyFunction: ActivityHandler = function (_input: any, context: InvocationContext): void {
context.log("Flaky Function Flaking!");
throw new Error("FlakyFunction flaked");
};
const flakyActivity: RegisteredActivity = df.app.activity("flakyFunction", {
handler: flakyFunction,
});
const callActivityWithRetry: OrchestrationHandler = function* (context: OrchestrationContext) {
const retryOptions: RetryOptions = new df.RetryOptions(1000, 2);
let returnValue: any;
try {
returnValue = yield (flakyActivity().withRetry(retryOptions));
} catch (e) {
context.log("Orchestrator caught exception. Flaky function is extremely flaky.");
}
return returnValue;
};
df.app.orchestration("callActivityWithRetry", callActivityWithRetry);
Does the line
returnValue = yield (flakyActivity().withRetry(retryOptions));
need the parentheses around the activity task, or could we have?
returnValue = yield flakyActivity().withRetry(retryOptions);
I'm just trying to understand if there's an order of evaluation problem here, which would explain the parenthesis. Just checking!
@davidmrdavid No it is not. I had that there first just because I was debugging something and thought that the precedence order might be causing it, but it turns out it wasn't. I just double checked and the parentheses are not required. I also update the PR description now.
Resolves #418. This makes it such that the registeration functions
app.orchestration()
andapp.activity()
return aRegisteredOrchestration
andRegisteredActivity
, respectively, which can be called to return a yieldableTask
, without having to callcontext.df.callSubOrchestrator()
,context.df.callSubOrchestratorWithRetry()
,context.df.callActivity()
, orcontext.df.callActivityWithRetry()
.Instead, you can call:
with
mySubOrchestraor
andmyActivity
being the result of registering the orchestration/activity. Detailed examples below:Calling activities and suborchestrators:
Before
After
With Retry:
Before
After