Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<!-- Packages can have independent versions and only increment when released -->
<Version>3.0.36$(VersionSuffix)</Version>
<Version>3.0.36-11991</Version>
<HostStorageVersion>5.0.0-beta.2$(VersionSuffix)</HostStorageVersion>
<LoggingVersion>4.0.3$(VersionSuffix)</LoggingVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Microsoft.Azure.WebJobs.Host
{
internal class BlobStorageConcurrencyStatusRepository : IConcurrencyStatusRepository
public class BlobStorageConcurrencyStatusRepository : IConcurrencyStatusRepository
{
private readonly IHostIdProvider _hostIdProvider;
private readonly ILogger _logger;
Expand Down
24 changes: 24 additions & 0 deletions src/Microsoft.Azure.WebJobs.Host/Hosting/ITriggerScaleConfigure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using Microsoft.Extensions.Hosting;

namespace Microsoft.Azure.WebJobs.Hosting
{
/// <summary>
/// Interface defining a trigger scale configuration action.
/// as part of host startup.
/// </summary>
public interface IConfigureTriggerScale
{
/// <summary>
/// Performs the scale configuration action for a trigger. The host will call this
/// method at the right time during scale host initialization for each trigger.
/// </summary>
/// <param name="builder">The <see cref="IHostBuilder"/> that can be used to
/// configure the trigger scale.</param>
/// <param name="triggerScaleContext">he <see cref="HostBuilderContext"/> hat can be used to
/// configure the trigger scale.</param>
void ConfigureTriggerScale(IHostBuilder builder, HostBuilderContext triggerScaleContext);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Linq;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host.Scale;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.EnvironmentVariables;
Expand Down Expand Up @@ -135,6 +136,22 @@ public static IHostBuilder ConfigureWebJobs(this IHostBuilder builder, Action<Ho
return builder;
}

/// <summary>
/// Applies scale configuration to the specified <see cref="IHostBuilder"/>.
/// </summary>
/// <param name="builder">The <see cref="IHostBuilder"/> to configure.</param>
/// <returns>The <see cref="IHostBuilder"/>.</returns>
public static IHostBuilder AddScale(this IHostBuilder builder)
{
builder.ConfigureServices((services) =>
{
services.TryAddSingleton<IScaleManager, ScaleManager>();
services.TryAddSingleton<IHostedService, ScaleMonitorService>();
});

return builder;
}

private static IConfigurationBuilder TryAddDefaultConfigurationSources(this IConfigurationBuilder config)
{
if (!config.Sources.OfType<JsonConfigurationSource>().Any(p => string.Equals(p.Path, "appsettings.json", StringComparison.OrdinalIgnoreCase)))
Expand Down
27 changes: 27 additions & 0 deletions src/Microsoft.Azure.WebJobs.Host/Scale/IScaleManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Azure.WebJobs.Host.Scale
{
public interface IScaleManager
{
/// <summary>
/// Gets aggrigated <see cref="ScaleStatus"> for all the trigger.
/// </summary>
/// <param name="context">The scale status context.</param>
/// <returns></returns>
Task<ScaleStatus> GetScaleStatusAsync(ScaleStatusContext context);

/// <summary>
/// Gets <see cref="ScaleStatus"> for each trigger.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
Task<IDictionary<string, ScaleStatus>> GetScaleStatusesAsync(ScaleStatusContext context);
}
}
28 changes: 28 additions & 0 deletions src/Microsoft.Azure.WebJobs.Host/Scale/IScaleMetricsRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Threading.Tasks;

namespace Microsoft.Azure.WebJobs.Host.Scale
{
/// <summary>
/// Interface defining methods for reading/writing scale metrics to a persistent store.
/// </summary>
public interface IScaleMetricsRepository
Comment thread
alrod marked this conversation as resolved.
{
/// <summary>
/// Persist the metrics for each monitor.
/// </summary>
/// <param name="monitorMetrics">The collection of metrics for each monitor.</param>
/// <returns>A task.</returns>
Task WriteMetricsAsync(IDictionary<IScaleMonitor, ScaleMetrics> monitorMetrics);

/// <summary>
/// Read the metrics.
/// </summary>
/// <param name="monitors">The current collection of monitors.</param>
/// <returns>Map of metrics per monitor.</returns>
Task<IDictionary<IScaleMonitor, IList<ScaleMetrics>>> ReadMetricsAsync(IEnumerable<IScaleMonitor> monitors);
}
}
Loading