logo

Crowdly

Browser

Add to Chrome

public class RateLimitDecorator : IApi { private readonly IApi _inner; ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

public class RateLimitDecorator : IApi

{

private readonly IApi _inner;

private readonly TokenBucket _bucket;

public RateLimitDecorator(IApi a, int m) => (_inner, _bucket) = (a, new TokenBucket(m));

public Response Call(string ep)

=> _bucket.Take() ? _inner.Call(ep) : Response.TooManyRequests();

}

Що спільного у всіх Decorator’ів?

100%
0%
0%
0%
More questions like this

Want instant access to all verified answers on do.ipo.kpi.ua?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome