Skip to content
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

Fixes to entity implementation #192

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/proto
20 changes: 20 additions & 0 deletions src/Shared/Grpc/ProtoUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using DurableTask.Core;
using DurableTask.Core.Command;
using DurableTask.Core.Entities;
using DurableTask.Core.Entities.OperationFormat;
using DurableTask.Core.History;
using Google.Protobuf;
Expand Down Expand Up @@ -631,6 +632,25 @@ internal static OrchestrationStatus ToCore(this P.OrchestrationStatus status)
return batchResult;
}

/// <summary>
/// Converts the gRPC representation of orchestrator entity parameters to the DT.Core representation.
/// </summary>
/// <param name="parameters">The DT.Core representation.</param>
/// <returns>The gRPC representation.</returns>
[return: NotNullIfNotNull("parameters")]
internal static TaskOrchestrationEntityParameters? ToCore(this P.OrchestratorEntityParameters? parameters)
{
if (parameters == null)
{
return null;
}

return new TaskOrchestrationEntityParameters()
{
EntityMessageReorderWindow = parameters.EntityMessageReorderWindow.ToTimeSpan(),
};
}

/// <summary>
/// Gets the approximate byte count for a <see cref="P.TaskFailureDetails" />.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@ public override async Task CreateTimer(DateTime fireAt, CancellationToken cancel
/// <inheritdoc/>
public override Task<T> WaitForExternalEvent<T>(string eventName, CancellationToken cancellationToken = default)
{
if (typeof(T) == typeof(OperationResult))
{
throw new ArgumentException($"the type {nameof(OperationResult)} cannot be used for application-defined events", nameof(T));
}

// Return immediately if this external event has already arrived.
if (this.externalEventBuffer.TryTake(eventName, out string? bufferedEventPayload))
{
Expand Down
6 changes: 3 additions & 3 deletions src/Worker/Core/Shims/TaskOrchestrationEntityContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override async Task<IAsyncDisposable> LockEntitiesAsync(IEnumerable<Entit
// entityMessageEvent.ToString());
}

this.wrapper.innerContext.SendEvent(entityMessageEvent.TargetInstance, entityMessageEvent.EventName, entityMessageEvent.ContentAsObject());
this.wrapper.innerContext.SendEvent(entityMessageEvent.TargetInstance, entityMessageEvent.EventName, entityMessageEvent);

OperationResult result = await this.wrapper.WaitForExternalEvent<OperationResult>(criticalSectionId.ToString());

Expand Down Expand Up @@ -155,7 +155,7 @@ public void ExitCriticalSection(Guid? matchCriticalSectionId = null)
// releaseMessage.EventContent);
}

this.wrapper.innerContext.SendEvent(releaseMessage.TargetInstance, releaseMessage.EventName, releaseMessage.ContentAsObject());
this.wrapper.innerContext.SendEvent(releaseMessage.TargetInstance, releaseMessage.EventName, releaseMessage);
}
}
}
Expand Down Expand Up @@ -212,7 +212,7 @@ Guid SendOperationMessage(string instanceId, string operationName, object? input
// entityMessageEvent.ToString());
}

this.wrapper.innerContext.SendEvent(entityMessageEvent.TargetInstance, entityMessageEvent.EventName, entityMessageEvent.ContentAsObject());
this.wrapper.innerContext.SendEvent(entityMessageEvent.TargetInstance, entityMessageEvent.EventName, entityMessageEvent);

return guid;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Worker/Grpc/GrpcOrchestrationRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static string LoadAndRun(
? DurableTaskShimFactory.Default
: ActivatorUtilities.GetServiceOrCreateInstance<DurableTaskShimFactory>(services);
TaskOrchestration shim = factory.CreateOrchestration(orchestratorName, implementation, parent);
TaskOrchestrationExecutor executor = new(runtimeState, shim, BehaviorOnContinueAsNew.Carryover);
TaskOrchestrationExecutor executor = new(runtimeState, shim, BehaviorOnContinueAsNew.Carryover, request.EntityParameters.ToCore());
OrchestratorExecutionResult result = executor.Execute();

P.OrchestratorResponse response = ProtoUtils.ConstructOrchestratorResponse(
Expand Down