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