8 types derived from RateLimitLease
Microsoft.AspNetCore.RateLimiting (1)
DefaultCombinedLease.cs (1)
8internal sealed class DefaultCombinedLease : RateLimitLease
Microsoft.AspNetCore.RateLimiting.Tests (1)
TestRateLimitLease.cs (1)
8internal class TestRateLimitLease : RateLimitLease
System.Threading.RateLimiting (6)
System\Threading\RateLimiting\ChainedPartitionedRateLimiter.cs (1)
171private sealed class CombinedRateLimitLease : RateLimitLease
System\Threading\RateLimiting\ConcurrencyLimiter.cs (1)
365private sealed class ConcurrencyLease : RateLimitLease
System\Threading\RateLimiting\FixedWindowRateLimiter.cs (1)
422private sealed class FixedWindowLease : RateLimitLease
System\Threading\RateLimiting\NoopLimiter.cs (1)
42private sealed class NoopLease : RateLimitLease
System\Threading\RateLimiting\SlidingWindowRateLimiter.cs (1)
435private sealed class SlidingWindowLease : RateLimitLease
System\Threading\RateLimiting\TokenBucketRateLimiter.cs (1)
436private sealed class TokenBucketLease : RateLimitLease
117 references to RateLimitLease
Microsoft.AspNetCore.ConcurrencyLimiter (6)
QueuePolicies\BasePolicy.cs (6)
15private readonly ConcurrentQueue<RateLimitLease> _leases = new ConcurrentQueue<RateLimitLease>(); 48var lease = _limiter.AttemptAcquire(); 73if (!_leases.TryDequeue(out var lease)) 86private async ValueTask<bool> Awaited(ValueTask<RateLimitLease> task) 88var lease = await task;
Microsoft.AspNetCore.RateLimiting (10)
DefaultCombinedLease.cs (4)
10private readonly RateLimitLease _globalLease; 11private readonly RateLimitLease _endpointLease; 14public DefaultCombinedLease(RateLimitLease globalLease, RateLimitLease endpointLease)
LeaseContext.cs (1)
12public RateLimitLease? Lease { get; init; }
OnRejectedContext.cs (1)
20/// Gets or sets the failed <see cref="RateLimitLease"/> that the OnRejected callback will have access to
RateLimitingMiddleware.cs (4)
181RateLimitLease? globalLease = null; 182RateLimitLease? endpointLease = null; 212RateLimitLease? globalLease = null; 213RateLimitLease? endpointLease = null;
Microsoft.AspNetCore.RateLimiting.Tests (14)
TestPartitionedRateLimiter.cs (8)
34protected override RateLimitLease AttemptAcquireCore(TResource resourceID, int permitCount) 40var leases = new List<RateLimitLease>(); 43var lease = limiter.AttemptAcquire(); 50foreach (var unusedLease in leases) 60protected override async ValueTask<RateLimitLease> AcquireAsyncCore(TResource resourceID, int permitCount, CancellationToken cancellationToken) 66var leases = new List<RateLimitLease>(); 71foreach (var lease in leases) 75foreach (var unusedLease in leases)
TestRateLimiter.cs (3)
24protected override RateLimitLease AttemptAcquireCore(int permitCount) 29protected override ValueTask<RateLimitLease> AcquireAsyncCore(int permitCount, CancellationToken cancellationToken) 32return new ValueTask<RateLimitLease>(new TestRateLimitLease(_alwaysAccept, null));
TestRateLimitLease.cs (3)
10internal List<RateLimitLease> _leases; 12public TestRateLimitLease(bool isAcquired, List<RateLimitLease> leases) 31foreach (var lease in _leases)
System.Threading.RateLimiting (87)
System\Threading\RateLimiting\ChainedPartitionedRateLimiter.cs (17)
55protected override RateLimitLease AttemptAcquireCore(TResource resource, int permitCount) 58RateLimitLease[]? leases = null; 61RateLimitLease? lease = null; 71RateLimitLease? notAcquiredLease = CommonAcquireLogic(exception, lease, ref leases, i, _limiters.Length); 81protected override async ValueTask<RateLimitLease> AcquireAsyncCore(TResource resource, int permitCount, CancellationToken cancellationToken) 84RateLimitLease[]? leases = null; 87RateLimitLease? lease = null; 97RateLimitLease? notAcquiredLease = CommonAcquireLogic(exception, lease, ref leases, i, _limiters.Length); 120private static RateLimitLease? CommonAcquireLogic(Exception? ex, RateLimitLease? lease, ref RateLimitLease[]? leases, int index, int length) 141leases ??= new RateLimitLease[length]; 146private static AggregateException? CommonDispose(RateLimitLease[]? leases, int i) 173private RateLimitLease[]? _leases; 176public CombinedRateLimitLease(RateLimitLease[] leases) 195foreach (RateLimitLease lease in _leases) 211foreach (RateLimitLease lease in _leases)
System\Threading\RateLimiting\ConcurrencyLimiter.cs (10)
79protected override RateLimitLease AttemptAcquireCore(int permitCount) 106if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease)) 118protected override ValueTask<RateLimitLease> AcquireAsyncCore(int permitCount, CancellationToken cancellationToken = default) 130return new ValueTask<RateLimitLease>(SuccessfulLease); 138if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease)) 140return new ValueTask<RateLimitLease>(lease); 181return new ValueTask<RateLimitLease>(QueueLimitLease); 190return new ValueTask<RateLimitLease>(request.Task); 194private bool TryLeaseUnsynchronized(int permitCount, [NotNullWhen(true)] out RateLimitLease? lease) 413private sealed class RequestRegistration : TaskCompletionSource<RateLimitLease>
System\Threading\RateLimiting\DefaultPartitionedRateLimiter.cs (2)
77protected override RateLimitLease AttemptAcquireCore(TResource resource, int permitCount) 82protected override ValueTask<RateLimitLease> AcquireAsyncCore(TResource resource, int permitCount, CancellationToken cancellationToken)
System\Threading\RateLimiting\FixedWindowRateLimiter.cs (12)
31private static readonly RateLimitLease SuccessfulLease = new FixedWindowLease(true, null); 32private static readonly RateLimitLease FailedLease = new FixedWindowLease(false, null); 99protected override RateLimitLease AttemptAcquireCore(int permitCount) 125if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease)) 136protected override ValueTask<RateLimitLease> AcquireAsyncCore(int permitCount, CancellationToken cancellationToken = default) 150return new ValueTask<RateLimitLease>(SuccessfulLease); 156if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease)) 158return new ValueTask<RateLimitLease>(lease); 199return new ValueTask<RateLimitLease>(CreateFailedWindowLease(permitCount)); 208return new ValueTask<RateLimitLease>(registration.Task); 221private bool TryLeaseUnsynchronized(int permitCount, [NotNullWhen(true)] out RateLimitLease? lease) 451private sealed class RequestRegistration : TaskCompletionSource<RateLimitLease>
System\Threading\RateLimiting\MetadataName.T.cs (1)
9/// A strongly-typed name of metadata that can be stored in a <see cref="RateLimitLease"/>.
System\Threading\RateLimiting\NoopLimiter.cs (4)
11private static readonly RateLimitLease _lease = new NoopLease(); 30protected override RateLimitLease AttemptAcquireCore(int permitCount) 36protected override ValueTask<RateLimitLease> AcquireAsyncCore(int permitCount, CancellationToken cancellationToken) 39return new ValueTask<RateLimitLease>(_lease);
System\Threading\RateLimiting\PartitionedRateLimiter.cs (1)
46/// <see cref="RateLimitLease"/>s returned will aggregate metadata and for duplicates use the value of the first lease with the same metadata name.
System\Threading\RateLimiting\PartitionedRateLimiter.T.cs (6)
30public RateLimitLease AttemptAcquire(TResource resource, int permitCount = 1) 46protected abstract RateLimitLease AttemptAcquireCore(TResource resource, int permitCount); 59public ValueTask<RateLimitLease> AcquireAsync(TResource resource, int permitCount = 1, CancellationToken cancellationToken = default) 68return new ValueTask<RateLimitLease>(Task.FromCanceled<RateLimitLease>(cancellationToken)); 81protected abstract ValueTask<RateLimitLease> AcquireAsyncCore(TResource resource, int permitCount, CancellationToken cancellationToken);
System\Threading\RateLimiting\RateLimiter.cs (6)
37public RateLimitLease AttemptAcquire(int permitCount = 1) 52protected abstract RateLimitLease AttemptAcquireCore(int permitCount); 64public ValueTask<RateLimitLease> AcquireAsync(int permitCount = 1, CancellationToken cancellationToken = default) 73return new ValueTask<RateLimitLease>(Task.FromCanceled<RateLimitLease>(cancellationToken)); 85protected abstract ValueTask<RateLimitLease> AcquireAsyncCore(int permitCount, CancellationToken cancellationToken);
System\Threading\RateLimiting\RateLimiterStatistics.cs (2)
27/// Gets the total number of failed <see cref="RateLimitLease"/>s returned. 32/// Gets the total number of successful <see cref="RateLimitLease"/>s returned.
System\Threading\RateLimiting\SlidingWindowRateLimiter.cs (12)
35private static readonly RateLimitLease SuccessfulLease = new SlidingWindowLease(true, null); 36private static readonly RateLimitLease FailedLease = new SlidingWindowLease(false, null); 113protected override RateLimitLease AttemptAcquireCore(int permitCount) 136if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease)) 148protected override ValueTask<RateLimitLease> AcquireAsyncCore(int permitCount, CancellationToken cancellationToken = default) 162return new ValueTask<RateLimitLease>(SuccessfulLease); 168if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease)) 170return new ValueTask<RateLimitLease>(lease); 211return new ValueTask<RateLimitLease>(FailedLease); 220return new ValueTask<RateLimitLease>(registration.Task); 224private bool TryLeaseUnsynchronized(int permitCount, [NotNullWhen(true)] out RateLimitLease? lease) 464private sealed class RequestRegistration : TaskCompletionSource<RateLimitLease>
System\Threading\RateLimiting\TokenBucketRateLimiter.cs (12)
33private static readonly RateLimitLease SuccessfulLease = new TokenBucketLease(true, null); 34private static readonly RateLimitLease FailedLease = new TokenBucketLease(false, null); 107protected override RateLimitLease AttemptAcquireCore(int tokenCount) 130if (TryLeaseUnsynchronized(tokenCount, out RateLimitLease? lease)) 141protected override ValueTask<RateLimitLease> AcquireAsyncCore(int tokenCount, CancellationToken cancellationToken = default) 155return new ValueTask<RateLimitLease>(SuccessfulLease); 161if (TryLeaseUnsynchronized(tokenCount, out RateLimitLease? lease)) 163return new ValueTask<RateLimitLease>(lease); 204return new ValueTask<RateLimitLease>(CreateFailedTokenLease(tokenCount)); 213return new ValueTask<RateLimitLease>(registration.Task); 228private bool TryLeaseUnsynchronized(int tokenCount, [NotNullWhen(true)] out RateLimitLease? lease) 465private sealed class RequestRegistration : TaskCompletionSource<RateLimitLease>
System\Threading\RateLimiting\TranslatingLimiter.cs (2)
30protected override RateLimitLease AttemptAcquireCore(TResource resource, int permitCount) 37protected override ValueTask<RateLimitLease> AcquireAsyncCore(TResource resource, int permitCount, CancellationToken cancellationToken)