Skip to content

Commit c6217da

Browse files
authored
Scaler apis (#9131)
1 parent a379410 commit c6217da

File tree

18 files changed

+110
-1260
lines changed

18 files changed

+110
-1260
lines changed

src/WebJobs.Script.WebHost/Controllers/HostController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,17 @@ public async Task<IActionResult> GetScaleStatus([FromBody] ScaleStatusContext co
317317
}
318318

319319
// TEMP: Once https://github.com/Azure/azure-functions-host/issues/5161 is fixed, we should take
320-
// FunctionsScaleManager as a parameter.
321-
if (Utility.TryGetHostService(scriptHostManager, out FunctionsScaleManager scaleManager))
320+
// IScaleStatusProvider as a parameter.
321+
if (Utility.TryGetHostService(scriptHostManager, out IScaleStatusProvider scaleStatusProvider))
322322
{
323-
var scaleStatus = await scaleManager.GetScaleStatusAsync(context);
323+
var scaleStatus = await scaleStatusProvider.GetScaleStatusAsync(context);
324324
return new ObjectResult(scaleStatus);
325325
}
326326
else
327327
{
328328
// This case should never happen. Because this action is marked RequiresRunningHost,
329329
// it's only invoked when the host is running, and if it's running, we'll have access
330-
// to the FunctionsScaleManager.
330+
// to the IScaleStatusProvider.
331331
return StatusCode(StatusCodes.Status503ServiceUnavailable);
332332
}
333333
}

src/WebJobs.Script.WebHost/DependencyInjection/DependencyValidator/DependencyValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ private static ExpectedDependencyBuilder CreateExpectedDependencies()
4848
.Expect<WorkerConsoleLogService>()
4949
.Expect<FunctionInvocationDispatcherShutdownManager>()
5050
.Expect<WorkerConcurrencyManager>()
51-
.Optional<FunctionsScaleMonitorService>()
5251
.Optional<FuncAppFileProvisioningService>() // Used by powershell.
5352
.Optional<JobHostService>() // Missing when host is offline.
5453
.Optional<FunctionsSyncService>() // Conditionally registered.
5554
.OptionalExternal("Microsoft.AspNetCore.DataProtection.Internal.DataProtectionHostedService", "Microsoft.AspNetCore.DataProtection", "adb9793829ddae60") // Popularly-registered by DataProtection.
5655
.OptionalExternal("Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckPublisherHostedService", "Microsoft.Extensions.Diagnostics.HealthChecks", "adb9793829ddae60") // Popularly-registered by Health Check Monitor.
5756
.OptionalExternal("OpenTelemetry.Extensions.Hosting.Implementation.TelemetryHostedService", "OpenTelemetry.Extensions.Hosting", "7bd6737fe5b67e3c") // Enable OpenTelemetry.Net instrumentation library
5857
.OptionalExternal("Microsoft.Azure.WebJobs.Hosting.PrimaryHostCoordinator", "Microsoft.Azure.WebJobs.Host", "31bf3856ad364e35")
59-
.OptionalExternal("Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManagerService", "Microsoft.Azure.WebJobs.Host", "31bf3856ad364e35");
58+
.OptionalExternal("Microsoft.Azure.WebJobs.Host.Scale.ConcurrencyManagerService", "Microsoft.Azure.WebJobs.Host", "31bf3856ad364e35")
59+
.OptionalExternal("Microsoft.Azure.WebJobs.Host.Scale.ScaleMonitorService", "Microsoft.Azure.WebJobs.Host", "31bf3856ad364e35");
6060

6161
expected.ExpectSubcollection<ILoggerProvider>()
6262
.Expect<FunctionFileLoggerProvider>()

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
7878
<PackageReference Include="Microsoft.Azure.Storage.File" Version="11.1.7" />
7979

80-
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.36" />
80+
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.37-11123" />
8181
<PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="5.0.0-beta.2-11957" />
8282
<PackageReference Include="Microsoft.Azure.WebSites.DataProtection" Version="2.1.91-alpha" />
8383
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="$(IdentityDependencyVersion)" />

src/WebJobs.Script.WebHost/WebScriptHostBuilderExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static IHostBuilder AddWebScriptHost(this IHostBuilder builder, IServiceP
131131
// EasyAuth must go after CORS, as CORS preflight requests can happen before authentication
132132
services.TryAddEnumerable(ServiceDescriptor.Singleton<IJobHostHttpMiddleware, JobHostEasyAuthMiddleware>());
133133
}
134-
services.TryAddSingleton<IScaleMetricsRepository, TableStorageScaleMetricsRepository>();
134+
services.AddSingleton<IScaleMetricsRepository, TableStorageScaleMetricsRepository>();
135135

136136
services.TryAddEnumerable(ServiceDescriptor.Singleton<IConcurrencyThrottleProvider, WorkerChannelThrottleProvider>());
137137

src/WebJobs.Script/Config/ScaleOptions.cs

Lines changed: 0 additions & 94 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using Microsoft.Azure.WebJobs.Host.Scale;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.Extensions.Options;
7+
8+
namespace Microsoft.Azure.WebJobs.Script.Configuration
9+
{
10+
internal class ScaleOptionsSetup : IConfigureOptions<ScaleOptions>
11+
{
12+
private readonly IEnvironment _environment;
13+
14+
public ScaleOptionsSetup(IEnvironment environment)
15+
{
16+
_environment = environment;
17+
}
18+
19+
public void Configure(ScaleOptions options)
20+
{
21+
options.IsRuntimeScalingEnabled = _environment.IsRuntimeScaleMonitoringEnabled();
22+
options.IsTargetScalingEnabled = _environment.IsTargetBasedScalingEnabled();
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)