Durable functions - 'Function chaining' scenario support #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose of the PR
The purpose is to seek feedback and also transfer my learnings to @tylerl0706
Not seeking to merge to
/devbranch, as the durable function is not in scope for the private preview (maybe not even in the scope of the public preview).But since I started the investigation, it's a better use of my time to finish it, to some extent, so that we don't lose the learnings and related knowledge.
Summary
This is the initial changes to support the "Function Chaining" pattern of the durable function.
The main work involved are from two aspects:
For (1), the solution is to take advantage of the async invocation APIs
BeginInvoke,EndInvokeandStop. AnAutoResetEventnamedactionEventis added toPowerShellManager, which will be passed toInvoke-ActivityFunctionAsyncalong with the history events. OncePowerShellManagerstarts the execution of an orchestration function byBeginInvoke, it will get anAsyncResultobject back, then it will wait on eitheractionEventorasyncResult.AsyncWaitHandleto be set.Invoke-ActivityFunctionAsyncis requesting for scheduling a new activity, andPowerShellManagerwill stop the execution by callingStop()and handle the requested actions.Inside the
Invoke-ActivityFunction, based on the history events, if it needs to schedule an activity function, then it creates actions and attaches them to the context object; if the activity function already completes, then it's a replay, and it just writes the result to the pipeline.For (2), I mimic the implementation of
durable-json how to handle messages related to durable function execution.