Skip to content

Commit 27083a2

Browse files
authored
Add overload to IDurabilityProviderFactory to support using TriggerMetadata from Azure Functions Scale (#3174)
* initial commit * udpate test * udpate interface with default info * remove unnecessary using * update interface * remove optional argument * remove warning * update version for private testing * udpate worker extension * make provider name azure managed const * fix format * update ver * udpate version and remove unnecessary using
1 parent 8d41dfb commit 27083a2

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

src/WebJobs.Extensions.DurableTask/IDurabilityProviderFactory.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
using System;
4+
using Microsoft.Azure.WebJobs.Host.Scale;
35

46
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
57
{
@@ -25,5 +27,18 @@ public interface IDurabilityProviderFactory
2527
/// <param name="attribute">A durable client attribute with parameters for the durability provider.</param>
2628
/// <returns>A durability provider to be used by a client function.</returns>
2729
DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute);
30+
31+
/// <summary>
32+
/// Creates or retrieves a cached durability provider to be used in a given function execution.
33+
/// </summary>
34+
/// <param name="attribute">A durable client attribute with parameters for the durability provider.</param>
35+
/// <param name="triggerMetadata">Trigger metadata used to create IOrchestrationService for functions scale scenarios.</param>
36+
/// <returns>A durability provider to be used by a client function.</returns>
37+
DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute, TriggerMetadata triggerMetadata)
38+
{
39+
// This method is not supported by this provider.
40+
// Only providers that require TriggerMetadata for scale should implement it.
41+
throw new NotImplementedException("This provider does not support GetDurabilityProvider with TriggerMetadata.");
42+
}
2843
}
2944
}

src/WebJobs.Extensions.DurableTask/Scale/DurableTaskTriggersScaleProvider.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Collections.Generic;
77
using System.ComponentModel;
88
using Microsoft.Azure.WebJobs.Host.Scale;
9-
using Microsoft.Extensions.DependencyInjection;
109
using Microsoft.Extensions.Logging;
1110
using Microsoft.Extensions.Options;
1211
using Newtonsoft.Json;
@@ -15,6 +14,8 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Scale
1514
{
1615
internal class DurableTaskTriggersScaleProvider : IScaleMonitorProvider, ITargetScalerProvider
1716
{
17+
private const string AzureManagedProviderName = "azureManaged";
18+
1819
private readonly IScaleMonitor monitor;
1920
private readonly ITargetScaler targetScaler;
2021
private readonly DurableTaskOptions options;
@@ -40,7 +41,16 @@ public DurableTaskTriggersScaleProvider(
4041
this.GetOptions(triggerMetadata);
4142

4243
IDurabilityProviderFactory durabilityProviderFactory = this.GetDurabilityProviderFactory();
43-
DurabilityProvider defaultDurabilityProvider = durabilityProviderFactory.GetDurabilityProvider();
44+
45+
DurabilityProvider defaultDurabilityProvider;
46+
if (string.Equals(durabilityProviderFactory.Name, AzureManagedProviderName, StringComparison.OrdinalIgnoreCase))
47+
{
48+
defaultDurabilityProvider = durabilityProviderFactory.GetDurabilityProvider(attribute: null, triggerMetadata);
49+
}
50+
else
51+
{
52+
defaultDurabilityProvider = durabilityProviderFactory.GetDurabilityProvider();
53+
}
4454

4555
// Note: `this.options` is populated from the trigger metadata above
4656
string? connectionName = GetConnectionName(durabilityProviderFactory, this.options);

src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<RootNamespace>Microsoft.Azure.WebJobs.Extensions.DurableTask</RootNamespace>
77
<MajorVersion>3</MajorVersion>
88
<MinorVersion>4</MinorVersion>
9-
<PatchVersion>0</PatchVersion>
9+
<PatchVersion>1</PatchVersion>
1010
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
1111
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
1212
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>

src/Worker.Extensions.DurableTask/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions;
66

77
// TODO: Find a way to generate this dynamically at build-time
8-
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.DurableTask", "3.4.0")]
8+
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.DurableTask", "3.4.1")]
99
[assembly: InternalsVisibleTo("Worker.Extensions.DurableTask.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cd1dabd5a893b40e75dc901fe7293db4a3caf9cd4d3e3ed6178d49cd476969abe74a9e0b7f4a0bb15edca48758155d35a4f05e6e852fff1b319d103b39ba04acbadd278c2753627c95e1f6f6582425374b92f51cca3deb0d2aab9de3ecda7753900a31f70a236f163006beefffe282888f85e3c76d1205ec7dfef7fa472a17b1")]

src/Worker.Extensions.DurableTask/Worker.Extensions.DurableTask.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile>
3030

3131
<!-- Version information -->
32-
<VersionPrefix>1.7.0</VersionPrefix>
32+
<VersionPrefix>1.7.1</VersionPrefix>
3333
<VersionSuffix></VersionSuffix>
3434
<AssemblyVersion>$(VersionPrefix).0</AssemblyVersion>
3535
<!-- FileVersionRevision is expected to be set by the CI. -->

test/FunctionsV2/EmulatorDurabilityProviderFactory.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
using DurableTask.Core;
54
using DurableTask.Emulator;
65

76
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask

0 commit comments

Comments
 (0)