Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

README.md

ratelimit-java

Rate Limit your Java app using http://www.ratelim.it

//export RATELIMIT_API_KEY= "ACCT_ID|APIKEY"
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");
}
<dependency>
  <groupId>it.ratelim</groupId>
  <artifactId>ratelimit-java</artifactId>
  <version>0.0.2</version>
</dependency>

See full documentation http://www.ratelim.it/documentation

Supports

Options and Defaults

ApiClient apiClient = new ApiClient.Builder()
        .setMemcachedClientIF(memcachedClient)
        .build();

 apiClient.limitCreate(RateLimitProtos.LimitDefinition.newBuilder()
        .setGroup("event:pageload")
        .setLimit(1)
        .setPolicyName(RateLimitProtos.LimitResponse.LimitPolicyNames.HOURLY_ROLLING)
        .build());
 
 apiClient.limitCreate(RateLimitProtos.LimitDefinition.newBuilder()
        .setGroup("event:activation")
        .setLimit(1)
        .setPolicyName(RateLimitProtos.LimitResponse.LimitPolicyNames.INFINITE)
        .build());
 
 
 public void trackEvent(String event, String userId) {
     if (apiClient.featureIsOnFor("Services::RateLimit", userId)) {
       if (apiClient.isPass(String.format("event:%s:%s", event, userId))) {
         actuallyTrackEvent(event);
       }
     }
   }



track_event("pageload:home_page", "1"); // will track
track_event("pageload:home_page", "1"); // will skip for the next hour
track_event("activation", "1"); // will track
track_event("activation", "1"); // will skip forever

Contributing to ratelimit-java

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2017 Jeff Dwyer. See LICENSE.txt for further details.

About

Rate Limit & Feature Flag Infrastructure as a Service

Resources

Releases

No releases published
You can’t perform that action at this time.