Skip to content

Commit f901cc8

Browse files
committed
updte comments
1 parent 5d8720c commit f901cc8

11 files changed

+41
-68
lines changed

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/AzureStorage/AzureStorageScalabilityProvider.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class AzureStorageScalabilityProvider : ScalabilityProvider
2222
private DurableTaskMetricsProvider singletonDurableTaskMetricsProvider;
2323

2424
/// <summary>
25-
/// Initializes a new <see cref="AzureStorageScalabilityProvider"/> instance for scaling using Azure Storage.
25+
/// Initializes a new instance of the <see cref="AzureStorageScalabilityProvider"/> class.
2626
/// </summary>
2727
/// <param name="storageAccountClientProvider">
2828
/// Provides Azure Storage clients using resolved configuration, including
@@ -41,18 +41,10 @@ public AzureStorageScalabilityProvider(
4141
}
4242

4343
/// <summary>
44-
/// The app setting containing the Azure Storage connection string.
44+
/// Gets the app setting containing the Azure Storage connection string.
4545
/// </summary>
4646
public override string ConnectionName => this.connectionName;
4747

48-
internal DurableTaskMetricsProvider GetMetricsProvider(
49-
string hubName,
50-
StorageAccountClientProvider clientProvider,
51-
ILogger metricsLogger)
52-
{
53-
return new DurableTaskMetricsProvider(hubName, metricsLogger, performanceMonitor: null, clientProvider);
54-
}
55-
5648
/// <inheritdoc/>
5749
/// Note: ScaleMonitor is not used in prod. Can be cleaned in future.
5850
public override bool TryGetScaleMonitor(
@@ -99,5 +91,13 @@ public override bool TryGetTargetScaler(
9991
return true;
10092
}
10193
}
94+
95+
internal DurableTaskMetricsProvider GetMetricsProvider(
96+
string hubName,
97+
StorageAccountClientProvider clientProvider,
98+
ILogger metricsLogger)
99+
{
100+
return new DurableTaskMetricsProvider(hubName, metricsLogger, performanceMonitor: null, clientProvider);
101+
}
102102
}
103103
}

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/AzureStorage/AzureStorageScalabilityProviderFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.AzureSto
1515
/// </summary>
1616
public class AzureStorageScalabilityProviderFactory : IScalabilityProviderFactory
1717
{
18-
private const string LoggerName = "Triggers.DurableTask.AzureStorage";
1918
internal const string ProviderName = "AzureStorage";
19+
private const string LoggerName = "Triggers.DurableTask.AzureStorage";
2020

2121
private readonly IStorageServiceClientProviderFactory clientProviderFactory;
2222
private readonly IConfiguration configuration;
@@ -49,12 +49,12 @@ public AzureStorageScalabilityProviderFactory(
4949
}
5050

5151
/// <summary>
52-
/// Name of this provider service.
52+
/// Gets name of this provider service.
5353
/// </summary>
5454
public virtual string Name => ProviderName;
5555

5656
/// <summary>
57-
/// Default connection name of this provider service.
57+
/// Gets default connection name of this provider service.
5858
/// </summary>
5959
public string DefaultConnectionName { get; }
6060

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/AzureStorage/DurableTaskMetricsProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class DurableTaskMetricsProvider
3939
/// <param name="storageAccountClientProvider">
4040
/// Provides Azure Storage clients required to access task hub resources.
4141
/// </param>
42+
/// Note: This file should remain partially aligned with Microsoft.Azure.WebJobs.Extensions.DurableTask/Listener/DurableTaskMetricsProvider.
4243
public DurableTaskMetricsProvider(
4344
string hubName,
4445
ILogger logger,

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/AzureStorage/DurableTaskScaleMonitor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.AzureStorage
1515
{
16-
//TODO: This class can be removed in future. As Scale Controller v3 doesn't use Scale Monitor.
16+
// TODO: This class can be removed in future. As Scale Controller v3 doesn't use Scale Monitor.
1717
// Keep it for now for backwards compatibility.
18+
// Note: This file should remain partially aligned with Microsoft.Azure.WebJobs.Extensions.DurableTask/Listener/DurableTaskScaleMonitor.
1819
internal sealed class DurableTaskScaleMonitor : IScaleMonitor<DurableTaskTriggerMetrics>
1920
{
2021
private readonly string hubName;

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/AzureStorage/DurableTaskTargetScaler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.AzureSto
1414
{
1515
/// <summary>
1616
/// Target scaler that computes the desired worker count based on scale metrics from the Azure Storage backend.
17+
/// Note: This file should remain partially aligned with Microsoft.Azure.WebJobs.Extensions.DurableTask/Listener/DurableTaskTargetScaler.
1718
/// </summary>
1819
public class DurableTaskTargetScaler : ITargetScaler
1920
{
@@ -24,7 +25,7 @@ public class DurableTaskTargetScaler : ITargetScaler
2425
private readonly string scaler;
2526

2627
/// <summary>
27-
/// Initializes a new instance of the <see cref="DurableTaskTargetScaler"/>.
28+
/// Initializes a new instance of the <see cref="DurableTaskTargetScaler"/> class.
2829
/// </summary>
2930
/// <param name="scalerId">
3031
/// The unique identifier for this target scaler.

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/AzureStorage/DurableTaskTriggerMetrics.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
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.Collections.Generic;
43
using Microsoft.Azure.WebJobs.Host.Scale;
54

65
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.AzureStorage
76
{
87
/// <summary>
98
/// Represents scale-related metrics for AzureStorage backend.
9+
/// Note: This file should remain partially aligned with Microsoft.Azure.WebJobs.Extensions.DurableTask/Listener/DurableTaskTriggerMetrics.
1010
/// </summary>
1111
public class DurableTaskTriggerMetrics : ScaleMetrics
1212
{
1313
/// <summary>
14-
/// The number of partitions in the task hub.
14+
/// Gets or sets the number of partitions in the task hub.
1515
/// </summary>
1616
public virtual int PartitionCount { get; set; }
1717

1818
/// <summary>
19-
/// The number of messages across control queues. This will
20-
/// be in the form of a serialized array of ints, e.g. "[1,2,3,4]".
19+
/// Gets or sets the number of messages across control queues.
2120
/// </summary>
2221
public virtual string ControlQueueLengths { get; set; }
2322

2423
/// <summary>
25-
/// The latency of messages across control queues. This will
26-
/// be in the form of a serialized array of TimeSpans in string
27-
/// format, e.g. "["00:00:00.0010000","00:00:00.0020000","00:00:00.0030000","00:00:00.0040000"]".
24+
/// Gets or sets the latency of messages across control queues.
2825
/// </summary>
2926
public string ControlQueueLatencies { get; set; }
3027

3128
/// <summary>
32-
/// The number of messages in the work-item queue.
29+
/// Gets or sets the number of messages in the work-item queue.
3330
/// </summary>
3431
public virtual int WorkItemQueueLength { get; set; }
3532

3633
/// <summary>
37-
/// The approximate age of the first work-item queue message. This
38-
/// will be a TimeSpan in string format, e.g. "00:00:00.0010000".
34+
/// Gets or sets the approximate age of the first work-item queue message.
3935
/// </summary>
4036
public string WorkItemQueueLatency { get; set; }
4137
}

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/DurableTaskScaleExtension.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ public DurableTaskScaleExtension(ILoggerFactory loggerFactory)
2929
this.logger.LogInformation("DurableTaskScaleExtension initialized.");
3030
}
3131

32-
/// <summary>
33-
/// Initializes the extension. Called by the WebJobs framework during host startup.
34-
/// </summary>
35-
/// <param name="context">The extension configuration context.</param>
36-
public void Initialize(ExtensionConfigContext context)
37-
{
38-
// The actual scaling work is done by DurableTaskTriggersScaleProvider.
39-
// This extension just needs to exist for the WebJobs framework to properly
40-
// initialize the host lifecycle.
41-
this.logger.LogInformation("DurableTaskScaleExtension.Initialize called.");
42-
}
43-
4432
/// <summary>
4533
/// Determines the scalability provider factory based on the given metadata.
4634
/// If no storage provider type is configured, defaults to AzureStorage.
@@ -83,5 +71,17 @@ public static IScalabilityProviderFactory GetScalabilityProviderFactory(
8371
throw new InvalidOperationException($"Storage provider type ({storageType?.ToString() ?? "null"}) was not found. Available storage providers: {string.Join(", ", factoryNames)}.", e);
8472
}
8573
}
74+
75+
/// <summary>
76+
/// Initializes the extension. Called by the WebJobs framework during host startup.
77+
/// </summary>
78+
/// <param name="context">The extension configuration context.</param>
79+
public void Initialize(ExtensionConfigContext context)
80+
{
81+
// The actual scaling work is done by DurableTaskTriggersScaleProvider.
82+
// This extension just needs to exist for the WebJobs framework to properly
83+
// initialize the host lifecycle.
84+
this.logger.LogInformation("DurableTaskScaleExtension.Initialize called.");
85+
}
8686
}
8787
}

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/DurableTaskTriggersScaleProvider.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public DurableTaskTriggersScaleProvider(
7474
ScalabilityProvider defaultscalabilityProvider = scalabilityProviderFactory.GetScalabilityProvider(metadata, triggerMetadata);
7575

7676
// Get connection name from metadata.StorageProvider
77-
string? connectionName = GetConnectionNameFromOptions(metadata.StorageProvider) ?? scalabilityProviderFactory.DefaultConnectionName;
77+
string? connectionName = TriggerMetadataExtensions.ResolveConnectionName(metadata.StorageProvider) ?? scalabilityProviderFactory.DefaultConnectionName;
7878

7979
logger.LogInformation(
8080
"Creating DurableTaskTriggersScaleProvider for function {FunctionName}: connectionName = '{ConnectionName}'",
@@ -96,28 +96,6 @@ public DurableTaskTriggersScaleProvider(
9696
metadata.TaskHubName);
9797
}
9898

99-
private static string? GetConnectionNameFromOptions(IDictionary<string, object>? storageProvider)
100-
{
101-
if (storageProvider == null)
102-
{
103-
return null;
104-
}
105-
106-
// Try connectionName first
107-
if (storageProvider.TryGetValue(DefaultConnectionName, out object? value1) && value1 is string s1 && !string.IsNullOrWhiteSpace(s1))
108-
{
109-
return s1;
110-
}
111-
112-
// Try connectionStringName
113-
if (storageProvider.TryGetValue(ConnectionNameOverride, out object? value2) && value2 is string s2 && !string.IsNullOrWhiteSpace(s2))
114-
{
115-
return s2;
116-
}
117-
118-
return null;
119-
}
120-
12199
/// <summary>
122100
/// Gets the scale monitor used to observe load and trigger scaling decisions.
123101
/// </summary>

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/IScalabilityProviderFactory.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale
1212
public interface IScalabilityProviderFactory
1313
{
1414
/// <summary>
15-
/// Specifies the Durability Provider Factory name.
15+
/// Gets the provider factory name.
1616
/// </summary>
1717
string Name { get; }
1818

@@ -23,16 +23,12 @@ public interface IScalabilityProviderFactory
2323

2424
/// <summary>
2525
/// Creates or retrieves a cached scalability provider.
26-
/// This method is used for both runtime-driven scaling and Scale Controller scenarios.
2726
/// </summary>
2827
/// <param name="metadata">
2928
/// The Durable Task metadata containing task hub name, max concurrency settings, and storage provider configuration.
30-
/// For runtime-driven scaling: constructed from DurableTaskOptions (host.json).
31-
/// For Scale Controller: deserialized from SyncTriggers payload.
3229
/// </param>
3330
/// <param name="triggerMetadata">
34-
/// Trigger metadata used to access Properties like token credentials (Scale Controller only).
35-
/// This is null for runtime-driven scaling since it runs in the host process.
31+
/// Trigger metadata provided by Scale Controller to access Properties like token credentials.
3632
/// </param>
3733
/// <returns>A scalability provider configured with the specified metadata.</returns>
3834
ScalabilityProvider GetScalabilityProvider(DurableTaskMetadata metadata, TriggerMetadata? triggerMetadata);

src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/StorageServiceClientProviderFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale
1111
{
1212
/// <summary>
13-
/// Factory for creating azure storage client providers.
13+
/// Factory for creating Azure Storage client providers for authenticating with the Azure Storage backend.
1414
/// </summary>
1515
public class StorageServiceClientProviderFactory : IStorageServiceClientProviderFactory
1616
{

0 commit comments

Comments
 (0)