Simple Rate Limit Try it

limiter =  RateLimit::Limiter.new(apikey: "ACCT_ID|APIKEY")

# only need to do this on startup
# limit to 1 per hour
limiter.create_limit("pageload", 1, RateLimIt::HOURLY_ROLLING)

if limiter.pass?("pageload")
  do_hourly_thing()
end
ApiClient apiClient = new ApiClient.Builder()
        .build();

apiClient.limitCreate(RateLimitProtos.LimitDefinition.newBuilder()
        .setGroup("pageload")
        .setLimit(1)
        .setPolicyName(RateLimitProtos.LimitResponse.LimitPolicyNames.HOURLY_ROLLING)
        .build());

if(apiClient.isPass("pageload")){
        System.out.println("do hourly thing");
}

Use the same limit definition for different users Try it

limiter = RateLimit::Limiter.new(apikey: "ACCT_ID|APIKEY")

# only need to do this on startup
# limit to 1 per hour
limiter.upsert_limit("pageload", 1, RateLimIt::HOURLY_ROLLING)


if limiter.pass?("pageload:/my_account/login/:user12312")
   # this will fire
   TrackingService.trackPage(user12312, "/my_account/login/")
end

if limiter.pass?("pageload:/my_account/login/:user456")
   # this will fire
   TrackingService.trackPage(user456, "/my_account/login/")
end

if limiter.pass?("pageload:/my_account/login/:user456")
   # this won't fire because we're over user456's limit this hour
   TrackingService.trackPage(user456, "/my_account/login/")
end

Override limits

limiter = RateLimit::Limiter.new(apikey: "ACCT_ID|APIKEY")

# only need to do this on startup
# limit to 1 per hour
limiter.upsert_limit("pageload", 1, RateLimIt::HOURLY_ROLLING)
# limit these pages to 1/sec
limiter.upsert_limit("pageload:/order_placed", 1, RateLimIt::SECOND)


if limiter.pass?("pageload:/my_account/login/:user12312")
   # this will fire 1 / hour
   TrackingService.trackPage(user12312, "/my_account/login/")
end

if limiter.pass?("pageload:/order_placed:user456")
   # this will match the more specific limit definition a fire 1/sec
   TrackingService.trackPage(user456, "/order_placed")
end