I do not see what is new, we have been using this already for a long time (see snippet below).
We recently switched to a naked HTTP request to use our own HTTP client configuration and better control the timeout from our side too.
This seems to work, but still is not the async model we would like to see, the await still blocks until the stream is returned. Executing this in a separate thread does also work, but is not a best practice in a backend API: REST calls should not take e.g. half an hour before returning to the caller.
We are now executing this blocking call from a K8s container.
Executing it in an App Service or Function kills the HTTP connection after a time smaller than it takes to generate the report, we have no control over this App Service timeout.
In fact, we are not looking for language-level async support but for a true async process.
I want to pass the request to an Aspose endpoint, and control should return immediately to the caller (even with an await).
The request should be enriched with a property that allows us to specify a callback URL (hook), that Aspose calls when the document is ready and stored on e.g. some cloud blob storage.
When Aspose performs the callback, it should contain a (signed) download URL for us to call and get the generated document.
Alternatively, instead of this hook, we could also pass a signed URL in the request that Aspose calls to directly store the generated document in e.g. our blob storage. Both Azure and AWS support this approach. An event handler on our side could pick it up.
private async Task<IO.Stream> ExecuteMailMergeOnline(ExecuteMailMergeOnlineRequest request)
//var output = await WordsApi.ExecuteMailMergeOnline(request);
var accessToken = await AccessToken();
var httpRequest = request.CreateHttpRequest(WordsApiConfiguration, null);
var response = await Http.SendHttpRequest(httpRequest, accessToken);
var output = await request.DeserializeResponse(response) as IO.Stream;