I would like to create a simple Calculator service that has a single method to add numbers. This Add
method should be async
and has to limit the number of concurrent calls being made at a given time. For instance, no more than 5 concurrent calls per second. If the rate limit is exceeded, the call should throw an exception.
The class should be like:
public class RateLimitingCalculator
{
public async Task<int> Add(int a, int b)
{
//...
}
}
Any ideas? I would like implement it with Reactive Extensions, but if it's better to use another strategy, I would stick to it!