Method Create
- Namespace
- MailFathom.Infrastructure.Security.Transport
- Assembly
- MailFathom.Infrastructure.dll
Create(int, int, int, int, int, TimeSpan, int)
Creates the limits a transport surface runs under.
public static TransportRateLimits Create(int maxConcurrentRequests, int maxConcurrentRequestsPerUser, int concurrencyQueueLimit, int tokenCapacity, int tokensPerReplenishmentPeriod, TimeSpan replenishmentPeriod, int requestQueueLimit)
Parameters
maxConcurrentRequestsintHow many requests the process serves at once on this surface.
maxConcurrentRequestsPerUserintHow many requests one user may have served at once on this surface.
concurrencyQueueLimitintHow many requests wait for a process-wide concurrency slot.
tokenCapacityintThe largest burst one user may spend at once.
tokensPerReplenishmentPeriodintHow much capacity one user gets back each period.
replenishmentPeriodTimeSpanHow often a user's spent capacity is restored.
requestQueueLimitintHow many of one user's requests wait for capacity.
Returns
- TransportRateLimits
The limits.
Remarks
The guards here are the invariants the type cannot exist without, not the ranges an operator is held to. A deployment's settings are checked against those before they reach this method, so that an operator reads every mistake at once instead of the first one to throw.
Exceptions
- ArgumentOutOfRangeException
Thrown when a value would leave the surface unbounded, unable to serve anything, unable to recover the capacity it hands out, or able to let one user hold every concurrency permit.