-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR feedback updates, fix build warnings, update CHANGELOG.md, etc.
- Loading branch information
Showing
7 changed files
with
54 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
src/DurableTask.SqlServer.AzureFunctions/SqlTargetScaler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#if FUNCTIONS_V4 | ||
namespace DurableTask.SqlServer.AzureFunctions | ||
{ | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.WebJobs.Host.Scale; | ||
|
||
#if !NETSTANDARD | ||
public class SqlTargetScaler : ITargetScaler | ||
{ | ||
readonly SqlMetricsProvider sqlMetricsProvider; | ||
readonly TargetScalerResult scaleResult; | ||
|
||
public SqlTargetScaler(string functionId, SqlMetricsProvider sqlMetricsProvider) | ||
public SqlTargetScaler(string taskHubName, SqlMetricsProvider sqlMetricsProvider) | ||
{ | ||
this.sqlMetricsProvider = sqlMetricsProvider; | ||
this.scaleResult = new TargetScalerResult(); | ||
this.TargetScalerDescriptor = new TargetScalerDescriptor(functionId); | ||
|
||
// Scalers in Durable Functions are shared for all functions in the same task hub. | ||
// So instead of using a function ID, we use the task hub name as the basis for the descriptor ID. | ||
string id = $"DurableTask-SqlServer:{taskHubName ?? "default"}"; | ||
this.TargetScalerDescriptor = new TargetScalerDescriptor(id); | ||
} | ||
|
||
public TargetScalerDescriptor TargetScalerDescriptor { get; private set; } | ||
|
||
public async Task<TargetScalerResult> GetScaleResultAsync(TargetScalerContext context) | ||
{ | ||
SqlScaleMetric sqlScaleMetric = await this.sqlMetricsProvider.GetMetricsAsync(); | ||
this.scaleResult.TargetWorkerCount = sqlScaleMetric.RecommendedReplicaCount; | ||
return this.scaleResult; | ||
return new TargetScalerResult | ||
{ | ||
TargetWorkerCount = sqlScaleMetric.RecommendedReplicaCount, | ||
}; | ||
} | ||
} | ||
#endif | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters