Expression-based activity invocations #1779
Replies: 2 comments
-
This is certainly an interesting suggestion, and I can see the appeal. At this time, unless we see some more customers ask for this, I don't see us adding this with first party support, as we don't want to add methods to the interface that only a handful of customers use to avoid confusion over which version of a method to use. This is something that can definitely be implemented in an extension method, so you could use it in your own code in the meantime. If this is something we decide to integrate down the line, I would love some further input from you. |
Beta Was this translation helpful? Give feedback.
-
Thanks :-) If this is implemented, it may be that we want to hide the whole thing behind some sort of proxy interface, much as is done with Durable Entities. Such a proxy interface could even route strongly-typed Orchestration invocations as well. |
Beta Was this translation helpful? Give feedback.
-
I'd like to be able to use expressions to call
context.CallActivityAsync
. This would provide stronger typing and remove the "magic string" for the function name.e.g. given the following function
You could use
context.CallActivityAsync(() => GetMyObject("Hello"))
instead of the current
context.CallActivityAsync<MyObject>(nameof(GetMyObject), "Hello")
The expression syntax could call the existing version for its implementation. A naive implementation would be something like:
Some further thoughts:
DynamicInvoke
; see e.g. here.ILog
) the values would be ignored.MethodCallExpression
(required / error level)Task<TResult> CallActivityAsync<TClass, TResult>(Expression<Func<TClass, TResult>> expr)
, which would then be called likecontext.CallActivityAsync<DiffClass, MyObject>(c => c.GetMyObject("Hello"))
.c
.Of course, you could have
Task
-returning andCallActivityWithRetryAsync
overloads as well.Beta Was this translation helpful? Give feedback.
All reactions