Skip to content

Commit

Permalink
Merge pull request #2583 from Azure/dev
Browse files Browse the repository at this point in the history
Merge dev to main for 2.11.3 release
  • Loading branch information
jviau authored Sep 13, 2023
2 parents e378bfa + 47bcc99 commit 32680a3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Bug Fixes

- Fix orchestration input missing [#2577](https://github.com/Azure/azure-functions-durable-extension/issues/2577)
- Address input issues when using .NET isolated (#2581)[https://github.com/Azure/azure-functions-durable-extension/issues/2581]

### Breaking Changes

Expand Down
70 changes: 50 additions & 20 deletions src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,50 +142,83 @@ public override Task<Empty> Hello(Empty request, ServerCallContext context)

public async override Task<P.CreateInstanceResponse> StartInstance(P.CreateInstanceRequest request, ServerCallContext context)
{
string? instanceId = null;
var instance = new OrchestrationInstance
{
InstanceId = request.InstanceId ?? Guid.NewGuid().ToString("N"),
ExecutionId = Guid.NewGuid().ToString(),
};

try
{
instanceId = await this.GetClient(context).StartNewAsync(request.Name, request.InstanceId, request.Input);
await this.GetDurabilityProvider(context).CreateTaskOrchestrationAsync(
new TaskMessage
{
Event = new ExecutionStartedEvent(-1, request.Input)
{
Name = request.Name,
Version = request.Version,
OrchestrationInstance = instance,
ScheduledStartTime = request.ScheduledStartTimestamp?.ToDateTime(),
},
OrchestrationInstance = instance,
},
this.GetStatusesNotToOverride());

return new P.CreateInstanceResponse
{
InstanceId = instanceId,
InstanceId = instance.InstanceId,
};
}
catch (InvalidOperationException)
{
throw new RpcException(new Status(StatusCode.AlreadyExists, $"An Orchestration instance with the ID {instanceId} already exists."));
throw new RpcException(new Status(StatusCode.AlreadyExists, $"An Orchestration instance with the ID {instance.InstanceId} already exists."));
}
}

public async override Task<P.RaiseEventResponse> RaiseEvent(P.RaiseEventRequest request, ServerCallContext context)
{
await this.GetClient(context).RaiseEventAsync(request.InstanceId, request.Name, request.Input);
await this.GetDurabilityProvider(context).SendTaskOrchestrationMessageAsync(
new TaskMessage
{
Event = new EventRaisedEvent(-1, request.Input)
{
Name = request.Name,
},
OrchestrationInstance = new OrchestrationInstance
{
InstanceId = request.InstanceId,
},
});

// No fields in the response
return new P.RaiseEventResponse();
}

public async override Task<P.TerminateResponse> TerminateInstance(P.TerminateRequest request, ServerCallContext context)
{
await this.GetClient(context).TerminateAsync(request.InstanceId, request.Output);
await this.GetDurabilityProvider(context).ForceTerminateTaskOrchestrationAsync(
request.InstanceId,
request.Output);

// No fields in the response
return new P.TerminateResponse();
}

public async override Task<P.SuspendResponse> SuspendInstance(P.SuspendRequest request, ServerCallContext context)
{
await this.GetClient(context).SuspendAsync(request.InstanceId, request.Reason);
await this.GetDurabilityProvider(context).SuspendTaskOrchestrationAsync(request.InstanceId, request.Reason);
return new P.SuspendResponse();
}

public async override Task<P.ResumeResponse> ResumeInstance(P.ResumeRequest request, ServerCallContext context)
{
await this.GetClient(context).ResumeAsync(request.InstanceId, request.Reason);
await this.GetDurabilityProvider(context).ResumeTaskOrchestrationAsync(request.InstanceId, request.Reason);
return new P.ResumeResponse();
}

public async override Task<P.RewindInstanceResponse> RewindInstance(P.RewindInstanceRequest request, ServerCallContext context)
{
#pragma warning disable CS0618 // Type or member is obsolete
await this.GetClient(context).RewindAsync(request.InstanceId, request.Reason);
#pragma warning restore CS0618 // Type or member is obsolete
await this.GetDurabilityProvider(context).RewindAsync(request.InstanceId, request.Reason);
return new P.RewindInstanceResponse();
}

Expand Down Expand Up @@ -305,21 +338,18 @@ private static P.GetInstanceResponse CreateGetInstanceResponse(OrchestrationStat
};
}

private DurableClientAttribute GetAttribute(ServerCallContext context)
private DurabilityProvider GetDurabilityProvider(ServerCallContext context)
{
string? taskHub = context.RequestHeaders.GetValue("Durable-TaskHub");
string? connectionName = context.RequestHeaders.GetValue("Durable-ConnectionName");
return new DurableClientAttribute() { TaskHub = taskHub, ConnectionName = connectionName };
}

private DurabilityProvider GetDurabilityProvider(ServerCallContext context)
{
return this.extension.GetDurabilityProvider(this.GetAttribute(context));
var attribute = new DurableClientAttribute() { TaskHub = taskHub, ConnectionName = connectionName };
return this.extension.GetDurabilityProvider(attribute);
}

private IDurableClient GetClient(ServerCallContext context)
private OrchestrationStatus[] GetStatusesNotToOverride()
{
return this.extension.GetClient(this.GetAttribute(context));
OverridableStates overridableStates = this.extension.Options.OverridableExistingInstanceStates;
return overridableStates.ToDedupeStatuses();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Microsoft.Azure.WebJobs.Extensions.DurableTask</RootNamespace>
<MajorVersion>2</MajorVersion>
<MinorVersion>11</MinorVersion>
<PatchVersion>2</PatchVersion>
<PatchVersion>3</PatchVersion>
<Version>$(MajorVersion).$(MinorVersion).$(PatchVersion)</Version>
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.18.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.13.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.14.1" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.DurableTask.Generators" Version="1.0.0-preview.1" OutputItemType="Analyzer" />
</ItemGroup>

Expand Down

0 comments on commit 32680a3

Please sign in to comment.