-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Change ConcurrenyMIddleware service extensions method #19324
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
Closed
Kahbazi
wants to merge
7
commits into
dotnet:master
from
Kahbazi:kahbazi/ConcurrencyMiddlewareExtensionsName
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c88b717
Change ConcurrenyMIddleware service extensions method
Kahbazi fa20a8c
Create ConcurrencyLimiterBuilder
Kahbazi 73746fb
Cleanup
Kahbazi ae39548
Use new Apis in oboletes method
Kahbazi 7f103ad
Move options to queue extension methods
Kahbazi 49bdc60
Move options to queue extension methods
Kahbazi 8448046
Move options to queue extension methods
Kahbazi 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
24 changes: 24 additions & 0 deletions
24
src/Middleware/ConcurrencyLimiter/src/ConcurrencyLimiterBuilder.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,24 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information | ||
|
|
||
| using System; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| namespace Microsoft.AspNetCore.ConcurrencyLimiter | ||
| { | ||
| public class ConcurrencyLimiterBuilder | ||
| { | ||
| public ConcurrencyLimiterBuilder(IServiceCollection services) | ||
| { | ||
| Services = services ?? throw new ArgumentNullException(nameof(services)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the <see cref="IServiceCollection"/> services are attached to. | ||
| /// </summary> | ||
| /// <value> | ||
| /// The <see cref="IServiceCollection"/> services are attached to. | ||
| /// </value> | ||
| public IServiceCollection Services { get; } | ||
| } | ||
| } |
67 changes: 67 additions & 0 deletions
67
src/Middleware/ConcurrencyLimiter/src/ConcurrencyLimiterBuilderExtensions.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,67 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information | ||
|
|
||
| using System; | ||
| using Microsoft.AspNetCore.ConcurrencyLimiter; | ||
|
|
||
| namespace Microsoft.Extensions.DependencyInjection | ||
| { | ||
| public static class ConcurrencyLimiterBuilderExtensions | ||
| { | ||
| /// <summary> | ||
| /// Tells <see cref="ConcurrencyLimiterMiddleware"/> to use a FIFO queue as its queueing strategy. | ||
| /// </summary> | ||
| /// <param name="builder"></param> | ||
| /// <param name="configure">Set the options used by the queue.</param> | ||
| /// <returns></returns> | ||
| public static ConcurrencyLimiterBuilder AddQueuePolicy(this ConcurrencyLimiterBuilder builder, Action<QueuePolicyOptions> configure) | ||
| { | ||
| builder.Services.AddOptions<QueuePolicyOptions>().Configure(configure); | ||
|
|
||
| builder.Services.AddSingleton<IQueuePolicy, QueuePolicy>(); | ||
| return builder; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Tells <see cref="ConcurrencyLimiterMiddleware"/> to use a FIFO queue as its queueing strategy. | ||
| /// </summary> | ||
| /// <param name="builder"></param> | ||
| /// <param name="configure">Set the options used by the queue.</param> | ||
| /// <returns></returns> | ||
| public static ConcurrencyLimiterBuilder AddQueuePolicy(this ConcurrencyLimiterBuilder builder, Action<QueuePolicyOptions, IServiceProvider> configure) | ||
| { | ||
| builder.Services.AddOptions<QueuePolicyOptions>().Configure(configure); | ||
halter73 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| builder.Services.AddSingleton<IQueuePolicy, QueuePolicy>(); | ||
| return builder; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Tells <see cref="ConcurrencyLimiterMiddleware"/> to use a LIFO stack as its queueing strategy. | ||
| /// </summary> | ||
| /// <param name="builder"></param> | ||
| /// <param name="configure">Set the options used by the queue.</param> | ||
| /// <returns></returns> | ||
| public static ConcurrencyLimiterBuilder AddStackPolicy(this ConcurrencyLimiterBuilder builder, Action<QueuePolicyOptions> configure) | ||
| { | ||
| builder.Services.AddOptions<QueuePolicyOptions>().Configure(configure); | ||
|
|
||
| builder.Services.AddSingleton<IQueuePolicy, StackPolicy>(); | ||
| return builder; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Tells <see cref="ConcurrencyLimiterMiddleware"/> to use a LIFO stack as its queueing strategy. | ||
| /// </summary> | ||
| /// <param name="builder"></param> | ||
| /// <param name="configure">Set the options used by the queue.</param> | ||
| /// <returns></returns> | ||
| public static ConcurrencyLimiterBuilder AddStackPolicy(this ConcurrencyLimiterBuilder builder, Action<QueuePolicyOptions, IServiceProvider> configure) | ||
| { | ||
| builder.Services.AddOptions<QueuePolicyOptions>().Configure(configure); | ||
|
|
||
| builder.Services.AddSingleton<IQueuePolicy, StackPolicy>(); | ||
| return builder; | ||
| } | ||
| } | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
src/Middleware/ConcurrencyLimiter/src/ConcurrencyMiddlewareServiceCollectionExtensions.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 Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using Microsoft.AspNetCore.ConcurrencyLimiter; | ||
|
|
||
| namespace Microsoft.Extensions.DependencyInjection | ||
| { | ||
| public static class ConcurrencyMiddlewareServiceCollectionExtensions | ||
| { | ||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| /// <param name="services">The <see cref="IServiceCollection"/> to add services to.</param> | ||
| /// <returns></returns> | ||
| public static ConcurrencyLimiterBuilder AddConcurrencyLimiter(this IServiceCollection services) | ||
| { | ||
| return new ConcurrencyLimiterBuilder(services); | ||
| } | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.