
Interface Throttler
 Throttler defined a simple method used to call throttler implementaton.
public void start()
Implementaton
ThrottleTimerImpl implement Throttler used to cyclical reset service visit counter.
| 1 | new Timer(true).schedule(new TimerTask() { | 
Counter
CallsCount use ConcurrentHashMap to implement multi thread save counter.
private Map<String, AtomicLong> tenantCallsCount = new ConcurrentHashMap<>();
POJO
Tenant represent a kind of business.
have properties name and allowedCallsPerSecond
Service
XXXService call Throttler to start reset thread.XXXService call counter to check whether ths visit under threshold.
| 1 | String tenantName = tenant.getName(); | 
Summary
Throttling is used to limit client visit frequency, so we need:
a overall situation counter
a daemonize thread resetor
a business represent pojo
a limited flow service