Skip to content

Commit

Permalink
PR feedback and minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cgillum committed Oct 10, 2024
1 parent b9d6891 commit 830934f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class SqlMetricsProvider
{
readonly SqlOrchestrationService service;

public SqlMetricsProvider(SqlOrchestrationService service, int? previousWorkerCount = null)
public SqlMetricsProvider(SqlOrchestrationService service)
{
this.service = service;
}
Expand Down
3 changes: 2 additions & 1 deletion src/DurableTask.SqlServer.AzureFunctions/SqlTargetScaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#if FUNCTIONS_V4
namespace DurableTask.SqlServer.AzureFunctions
{
using System;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Host.Scale;

Expand All @@ -28,7 +29,7 @@ public async Task<TargetScalerResult> GetScaleResultAsync(TargetScalerContext co
SqlScaleMetric sqlScaleMetric = await this.sqlMetricsProvider.GetMetricsAsync();
return new TargetScalerResult
{
TargetWorkerCount = sqlScaleMetric.RecommendedReplicaCount,
TargetWorkerCount = Math.Max(0, sqlScaleMetric.RecommendedReplicaCount),
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@

namespace DurableTask.SqlServer.AzureFunctions.Tests
{
using System;
using DurableTask.Core;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Azure.WebJobs.Host.Scale;
using Microsoft.Extensions.Logging;
using Moq;
using Xunit;
using Xunit.Abstractions;

public class TargetBasedScalingTests
{
Expand All @@ -21,10 +18,10 @@ public TargetBasedScalingTests()
{
this.orchestrationServiceMock = new Mock<IOrchestrationService>(MockBehavior.Strict);

SqlOrchestrationService? nullServiceArg = null; // not needed for this test
this.metricsProviderMock = new Mock<SqlMetricsProvider>(
MockBehavior.Strict,
null,
null);
behavior: MockBehavior.Strict,
nullServiceArg);
}

[Theory]
Expand All @@ -40,14 +37,14 @@ public async void TargetBasedScalingTest(int expectedTargetWorkerCount)
new Mock<IOrchestrationServiceClient>().Object,
"connectionName");

SqlScaleMetric sqlScaleMetric = new SqlScaleMetric()
var sqlScaleMetric = new SqlScaleMetric()
{
RecommendedReplicaCount = expectedTargetWorkerCount,
};

this.metricsProviderMock.Setup(m => m.GetMetricsAsync(null)).ReturnsAsync(sqlScaleMetric);

SqlTargetScaler targetScaler = new SqlTargetScaler(
var targetScaler = new SqlTargetScaler(
"functionId",
this.metricsProviderMock.Object);

Expand Down

0 comments on commit 830934f

Please sign in to comment.