RateLim.it API Client

API Client for http://www.ratelim.it: rate limits, feature flags and semaphores as a service

License

License

Categories

Categories

Java Languages
GroupId

GroupId

it.ratelim
ArtifactId

ArtifactId

ratelimit-java
Last Version

Last Version

0.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

RateLim.it API Client
API Client for http://www.ratelim.it: rate limits, feature flags and semaphores as a service
Source Code Management

Source Code Management

https://github.com/jdwyah/ratelimit-java

Download ratelimit-java

How to add to project

<!-- https://jarcasting.com/artifacts/it.ratelim/ratelimit-java/ -->
<dependency>
    <groupId>it.ratelim</groupId>
    <artifactId>ratelimit-java</artifactId>
    <version>0.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/it.ratelim/ratelimit-java/
implementation 'it.ratelim:ratelimit-java:0.0.5'
// https://jarcasting.com/artifacts/it.ratelim/ratelimit-java/
implementation ("it.ratelim:ratelimit-java:0.0.5")
'it.ratelim:ratelimit-java:jar:0.0.5'
<dependency org="it.ratelim" name="ratelimit-java" rev="0.0.5">
  <artifact name="ratelimit-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='it.ratelim', module='ratelimit-java', version='0.0.5')
)
libraryDependencies += "it.ratelim" % "ratelimit-java" % "0.0.5"
[it.ratelim/ratelimit-java "0.0.5"]

Dependencies

compile (10)

Group / Artifact Type Version
com.google.protobuf : protobuf-java jar 2.4.1
org.slf4j : slf4j-api jar 1.7.22
com.google.guava : guava jar 18.0
net.spy : spymemcached jar 2.12.2
biz.paluch.redis : lettuce jar 4.3.0.Final
io.dropwizard.metrics : metrics-core jar 3.1.2
io.dropwizard.metrics : metrics-annotation jar 3.1.2
joda-time : joda-time jar 2.9.6
com.google.inject : guice jar 4.1.0
org.apache.httpcomponents : httpclient jar 4.5.2

test (3)

Group / Artifact Type Version
org.mockito : mockito-core jar 1.10.19
junit : junit jar 4.11
org.assertj : assertj-core jar 3.0.0

Project Modules

There are no modules declared in this project.

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.

Versions

Version
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1