-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-add ScheduledStartTime to orchestration scheduling in .NET isolated #2805
Changes from all commits
dd7a431
6a5632e
1a17e1a
cabe839
18e491d
a163ecc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,11 +154,26 @@ public override Task<Empty> Hello(Empty request, ServerCallContext context) | |
{ | ||
try | ||
{ | ||
string instanceId = await this.GetClient(context).StartNewAsync( | ||
request.Name, request.InstanceId, Raw(request.Input)); | ||
string instanceId = request.InstanceId ?? Guid.NewGuid().ToString("N"); | ||
TaskHubClient taskhubClient = new TaskHubClient(this.GetDurabilityProvider(context)); | ||
OrchestrationInstance instance; | ||
|
||
// TODO: Ideally, we'd have a single method in the taskhubClient that can handle both scheduled and non-scheduled starts. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this was addressed in the durable-dotnet |
||
// TODO: the type of `ScheduledStartTimestamp` is not nullable. Can we change it to `DateTime?` in the proto file? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe proto uses its own type: |
||
if (request.ScheduledStartTimestamp != null) | ||
{ | ||
instance = await taskhubClient.CreateScheduledOrchestrationInstanceAsync( | ||
name: request.Name, version: request.Version, instanceId: instanceId, input: Raw(request.Input), startAt: request.ScheduledStartTimestamp.ToDateTime()); | ||
} | ||
else | ||
{ | ||
instance = await taskhubClient.CreateOrchestrationInstanceAsync(request.Name, request.Version, instanceId, Raw(request.Input)); | ||
} | ||
|
||
// TODO: should this not include the ExecutionId and other elements of the taskhubClient response? | ||
return new P.CreateInstanceResponse | ||
{ | ||
InstanceId = instanceId, | ||
InstanceId = instance.InstanceId, | ||
}; | ||
} | ||
catch (OrchestrationAlreadyExistsException) | ||
|
@@ -231,13 +246,13 @@ public override Task<Empty> Hello(Empty request, ServerCallContext context) | |
EntityBackendQueries.EntityQueryResult result = await entityOrchestrationService.EntityBackendQueries!.QueryEntitiesAsync( | ||
new EntityBackendQueries.EntityQuery() | ||
{ | ||
InstanceIdStartsWith = query.InstanceIdStartsWith, | ||
LastModifiedFrom = query.LastModifiedFrom?.ToDateTime(), | ||
LastModifiedTo = query.LastModifiedTo?.ToDateTime(), | ||
IncludeTransient = query.IncludeTransient, | ||
IncludeState = query.IncludeState, | ||
ContinuationToken = query.ContinuationToken, | ||
PageSize = query.PageSize, | ||
InstanceIdStartsWith = query.InstanceIdStartsWith, | ||
LastModifiedFrom = query.LastModifiedFrom?.ToDateTime(), | ||
LastModifiedTo = query.LastModifiedTo?.ToDateTime(), | ||
IncludeTransient = query.IncludeTransient, | ||
IncludeState = query.IncludeState, | ||
ContinuationToken = query.ContinuationToken, | ||
PageSize = query.PageSize, | ||
Comment on lines
-234
to
+255
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ran a formatter and it fixed this. |
||
}, | ||
context.CancellationToken); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Text.Json.Nodes; | ||
|
||
namespace Microsoft.Azure.Durable.Tests.DotnetIsolatedE2E; | ||
|
||
internal class DurableHelpers | ||
{ | ||
static readonly HttpClient _httpClient = new HttpClient(); | ||
|
||
internal class OrchestrationStatusDetails | ||
{ | ||
public string RuntimeStatus { get; set; } = string.Empty; | ||
public string Input { get; set; } = string.Empty; | ||
public string Output { get; set; } = string.Empty; | ||
public DateTime CreatedTime { get; set; } | ||
public DateTime LastUpdatedTime { get; set; } | ||
public OrchestrationStatusDetails(string statusQueryResponse) | ||
{ | ||
JsonNode? statusQueryJsonNode = JsonNode.Parse(statusQueryResponse); | ||
if (statusQueryJsonNode == null) | ||
{ | ||
return; | ||
} | ||
this.RuntimeStatus = statusQueryJsonNode["runtimeStatus"]?.GetValue<string>() ?? string.Empty; | ||
this.Input = statusQueryJsonNode["input"]?.ToString() ?? string.Empty; | ||
this.Output = statusQueryJsonNode["output"]?.ToString() ?? string.Empty; | ||
this.CreatedTime = DateTime.Parse(statusQueryJsonNode["createdTime"]?.GetValue<string>() ?? string.Empty).ToUniversalTime(); | ||
this.LastUpdatedTime = DateTime.Parse(statusQueryJsonNode["lastUpdatedTime"]?.GetValue<string>() ?? string.Empty).ToUniversalTime(); | ||
} | ||
} | ||
|
||
internal static string ParseStatusQueryGetUri(HttpResponseMessage invocationStartResponse) | ||
{ | ||
string? responseString = invocationStartResponse.Content?.ReadAsStringAsync().Result; | ||
|
||
if (string.IsNullOrEmpty(responseString)) | ||
{ | ||
return string.Empty; | ||
} | ||
JsonNode? responseJsonNode = JsonNode.Parse(responseString); | ||
if (responseJsonNode == null) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
string? statusQueryGetUri = responseJsonNode["StatusQueryGetUri"]?.GetValue<string>(); | ||
return statusQueryGetUri ?? string.Empty; | ||
} | ||
internal static OrchestrationStatusDetails GetRunningOrchestrationDetails(string statusQueryGetUri) | ||
{ | ||
var statusQueryResponse = _httpClient.GetAsync(statusQueryGetUri); | ||
|
||
string? statusQueryResponseString = statusQueryResponse.Result.Content.ReadAsStringAsync().Result; | ||
|
||
return new OrchestrationStatusDetails(statusQueryResponseString); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to also provider
ILoggerFactory
to the ctor