-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,4 +86,5 @@ public long getLimit() { | |
return limit; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...limitj-inmemory/src/main/java/es/moki/ratelimitj/inmemory/InMemoryRateLimiterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package es.moki.ratelimitj.inmemory; | ||
|
||
|
||
import es.moki.ratelimitj.core.limiter.request.AsyncRequestRateLimiter; | ||
import es.moki.ratelimitj.core.limiter.request.ReactiveRequestRateLimiter; | ||
import es.moki.ratelimitj.core.limiter.request.RequestLimitRule; | ||
import es.moki.ratelimitj.core.limiter.request.RequestRateLimiter; | ||
import es.moki.ratelimitj.core.limiter.request.RequestRateLimiterFactory; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
public class InMemoryRateLimiterFactory implements RequestRateLimiterFactory { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(InMemoryRateLimiterFactory.class); | ||
|
||
@Override | ||
public RequestRateLimiter getInstance(Set<RequestLimitRule> rules) { | ||
LOG.info("creating new InMemorySlidingWindowRequestRateLimiter"); | ||
return lookupInstance(rules); | ||
} | ||
|
||
@Override | ||
public AsyncRequestRateLimiter getInstanceAsync(Set<RequestLimitRule> rules) { | ||
throw new RuntimeException("In memory async not yet implemented"); | ||
} | ||
|
||
@Override | ||
public ReactiveRequestRateLimiter getInstanceReactive(Set<RequestLimitRule> rules) { | ||
throw new RuntimeException("In memory reactive not yet implemented"); | ||
} | ||
|
||
private RequestRateLimiter lookupInstance(Set<RequestLimitRule> rules) { | ||
return new InMemorySlidingWindowRequestRateLimiter(rules); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters