Improve handling of non-HTTP context in HttpEndpoint
Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions.
This commit is contained in:
parent
023ef267b5
commit
af9862440f
|
|
@ -166,7 +166,7 @@ public class HttpEndpoint : Trigger<HttpRequest>
|
|||
|
||||
if (!context.IsTriggerOfWorkflow())
|
||||
{
|
||||
context.CreateBookmarks(GetBookmarkPayloads(context.ExpressionExecutionContext), includeActivityInstanceId: false);
|
||||
context.CreateBookmarks(GetBookmarkPayloads(context.ExpressionExecutionContext), includeActivityInstanceId: false, callback: OnResumeAsync);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -191,8 +191,10 @@ public class HttpEndpoint : Trigger<HttpRequest>
|
|||
|
||||
if (httpContext == null)
|
||||
{
|
||||
// We're not in an HTTP context, so let's fail.
|
||||
throw new Exception("Cannot execute in a non-HTTP context");
|
||||
// We're executing in a non-HTTP context (e.g. in a virtual actor).
|
||||
// Create a bookmark to allow the invoker to export the state and resume execution from there.
|
||||
context.CreateBookmark(OnResumeAsync, BookmarkMetadata.HttpCrossBoundary);
|
||||
return;
|
||||
}
|
||||
|
||||
await HandleRequestAsync(context, httpContext);
|
||||
|
|
|
|||
Loading…
Reference in a new issue