@Override
    public void accept(String bucketId, RateBucketPeriod period, long limit, long increment,
            IAsyncResultHandler<RateLimitResponse> handler) {
        RateLimiterBucket newBucket = new RateLimiterBucket();
        RateLimiterBucket existingBucket = buckets.putIfAbsent(bucketId, newBucket);
        RateLimiterBucket bucket = existingBucket == null ? newBucket : existingBucket;
        
        boolean rateModified = bucket.resetIfNecessary(period);

        RateLimitResponse response = new RateLimitResponse();
        if (bucket.getCount() > limit) {
            response.setAccepted(false);
        } else {
            response.setAccepted(bucket.getCount() < limit);
            bucket.setCount(bucket.getCount() + increment);
            bucket.setLast(System.currentTimeMillis());
            rateModified = true;
        }
        
        if (rateModified) {
            lastModifiedOn = System.currentTimeMillis();
        }
        
        int reset = (int) (bucket.getResetMillis(period) / 1000L);
        response.setReset(reset);
        response.setRemaining(limit - bucket.getCount());
        handler.handle(AsyncResultImpl.<RateLimitResponse>create(response));
    }
@ Override public void accept ( String bucketId , RateBucketPeriod period , long limit , long increment , IAsyncResultHandler < RateLimitResponse > handler ) { RateLimiterBucket newBucket = new RateLimiterBucket ( ) ; RateLimiterBucket existingBucket = buckets . putIfAbsent ( bucketId , newBucket ) ; RateLimiterBucket bucket = existingBucket == null ? newBucket : existingBucket ; boolean rateModified = bucket . resetIfNecessary ( period ) ; RateLimitResponse response = new RateLimitResponse ( ) ; if ( bucket . getCount ( ) > limit ) { response . setAccepted ( false ) ; } else { response . setAccepted ( bucket . getCount ( ) < limit ) ; bucket . setCount ( bucket . getCount ( ) + increment ) ; bucket . setLast ( System . currentTimeMillis ( ) ) ; rateModified = true ; } if ( rateModified ) { lastModifiedOn = System . currentTimeMillis ( ) ; } int reset = ( int ) ( bucket . getResetMillis ( period ) / 1000L ) ; response . setReset ( reset ) ; response . setRemaining ( limit - bucket . getCount ( ) ) ; handler . handle ( AsyncResultImpl . < RateLimitResponse > create ( response ) ) ; }
@see io.apiman.gateway.engine.components.IRateLimiterComponent#accept(java.lang.String, io.apiman.gateway.engine.rates.RateBucketPeriod, long, long, io.apiman.gateway.engine.async.IAsyncResultHandler)