Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1.  
  2. public class FixedWindowRecord extends AbstractTokenRecord {
  3.    
  4.     private Instant windowEnd;
  5.    
  6.     ...
  7.  
  8.  
  9.     @Override
  10.     public RateLimitRecord updateWith(RefillPolicy policy, Instant requestTs) {
  11.         if (requestTs.isAfter(windowEnd)) {
  12.             return new FixedWindowRecord(policy.getCapacity(), windowEnd.plus(policy.getSamplingPeriod()));
  13.         }
  14.         return this;
  15.     }
  16.    
  17.     ...
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement