-
Notifications
You must be signed in to change notification settings - Fork 359
Scaler apis #2954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Scaler apis #2954
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
705526e
Unifying scale logic
alrod 79a0486
Scale API refinements
mathewc d7bd09e
Adding host options
alrod 49ede7a
Adding hostig config to webjobs sdk
alrod 3e3b1a0
Fix some issues
alrod 8ad30bd
Update to 3.0.37
alrod c7bf959
Fix VersionSuffix
alrod 476ba91
Scaler API updates
mathewc c1a8a93
Merge branch 'scaler-apis-mathewc' into scaler-apis
alrod d6f781d
Fix commnets
alrod 5d77b9a
Remove some APIs
alrod 79d9086
Fix Microsoft.FeatureManagement reference
alrod e2b08af
AddHostedService for ScaleMonitorService
alrod 3d15a6a
Changing FeatureManagement to IConfiguration
alrod b59bf70
Fix ScaleManagerTests
alrod b7479b5
Fix comments
alrod 256602f
Making GetScalersToSample static
alrod d101ac2
Fix ScaleOptions logging
alrod 8b6936a
Fix typo
alrod 87d1cc2
Fix Vincent comments
alrod 00bf27f
Scaler API updates
mathewc bd3ebb0
Fix comments
alrod 4467104
Fix comments
alrod e0c7520
AddOptionsLogging fix
alrod 9f68638
Always create properties in TriggerMetadata
alrod 26ed467
Introducing IScaleStatusProvider
alrod fcc5aaf
Fix ScaleHostEndToEndTests
alrod bdf6ac7
Last fixes
alrod 82cd90a
Fix AsyncChainEndToEndTests
alrod be2550e
Try to fix CI
alrod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
33 changes: 33 additions & 0 deletions
33
src/Microsoft.Azure.WebJobs.Host/Scale/AggregateScaleStatus.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // 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; | ||
|
|
||
| namespace Microsoft.Azure.WebJobs.Host.Scale | ||
| { | ||
| /// <summary> | ||
| /// Represents the aggregate scale status across all functions being monitored by the host. | ||
| /// </summary> | ||
| public class AggregateScaleStatus | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the aggregate scale vote. | ||
| /// </summary> | ||
| public ScaleVote Vote { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the aggregate target worker count. | ||
| /// </summary> | ||
| public int? TargetWorkerCount { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the individual <see cref="ScaleStatus"/>s for all functions being monitored. | ||
| /// </summary> | ||
| public IDictionary<string, ScaleStatus> FunctionScaleStatuses { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the individual <see cref="TargetScalerResult"/>s for all functions being monitored. | ||
| /// </summary> | ||
| public IDictionary<string, TargetScalerResult> FunctionTargetScalerResults { get; set; } | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.Azure.WebJobs.Host/Scale/IScaleMetricsRepository.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -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 | ||
| { | ||
| /// <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); | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/Microsoft.Azure.WebJobs.Host/Scale/IScaleStatusProvider.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.Azure.WebJobs.Host.Scale | ||
| { | ||
| /// <summary> | ||
| /// Interface for providing aggregate scale status across all functions being monitored by the host. | ||
| /// </summary> | ||
| public interface IScaleStatusProvider | ||
| { | ||
| /// <summary> | ||
| /// Gets the scale status for all functions being monitored by the host. | ||
| /// </summary> | ||
| /// <param name="context">The <see cref="ScaleStatusContext"/>.</param> | ||
| /// <returns>A task that returns the <see cref="AggregateScaleStatus"/>.</returns> | ||
| Task<AggregateScaleStatus> GetScaleStatusAsync(ScaleStatusContext context); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/Microsoft.Azure.WebJobs.Host/Scale/NullScaleMetricsRepository.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // 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 | ||
| { | ||
| internal class NullScaleMetricsRepository : IScaleMetricsRepository | ||
| { | ||
| private IDictionary<IScaleMonitor, IList<ScaleMetrics>> _emptyMetrics = new Dictionary<IScaleMonitor, IList<ScaleMetrics>>(); | ||
|
|
||
| public Task WriteMetricsAsync(IDictionary<IScaleMonitor, ScaleMetrics> monitorMetrics) | ||
| { | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| public Task<IDictionary<IScaleMonitor, IList<ScaleMetrics>>> ReadMetricsAsync(IEnumerable<IScaleMonitor> monitors) | ||
| { | ||
| return Task.FromResult((IDictionary<IScaleMonitor, IList<ScaleMetrics>>)_emptyMetrics); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to ever be called by a customer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this will be called from ScaleController, see example here:
https://github.com/Azure/azure-webjobs-sdk/blob/scaler-apis/test/Microsoft.Azure.WebJobs.Host.EndToEndTests/Scale/ScaleHostEndToEndTests.cs#L84
Function host is not supposed to call this.