Class RateLimitingMemStorePlugin
java.lang.Object
io.vertigo.vega.plugins.ratelimiting.mem.RateLimitingMemStorePlugin
- All Implemented Interfaces:
io.vertigo.core.node.component.CoreComponent,io.vertigo.core.node.component.Plugin,io.vertigo.core.node.definition.DefinitionProvider,io.vertigo.core.node.definition.SimpleDefinitionProvider,RateLimitingStorePlugin
public final class RateLimitingMemStorePlugin
extends Object
implements RateLimitingStorePlugin, io.vertigo.core.node.definition.SimpleDefinitionProvider
Rate limiting counting in memory storage.
- Author:
- npiedeloup
-
Constructor Summary
ConstructorsConstructorDescriptionRateLimitingMemStorePlugin(Optional<Integer> windowSeconds, Optional<Long> maxBanishSeconds) -
Method Summary
Modifier and TypeMethodDescriptionvoidbanishUntil(String userKey, Instant banishUntil) Set banish until instant for a userKey.voidCancel all banishments.voidcancelBanishment(String userKey) Cancel banishment of a userkey.voidextendsWindow(String userKey, long newWindowSeconds) getBanishInstant(String userKey) Get banish until instant.longgetFirstHitAgeSecond(String userKey) Get first hit age for a userKey.intincrementBanishCounter(String userKey, long maxBanishSeconds) Prepare banishment, increment and get banish counter.List<? extends io.vertigo.core.node.definition.Definition> provideDefinitions(io.vertigo.core.node.definition.DefinitionSpace definitionSpace) longremainingSeconds(String userKey) Get remaining seconds in window for a userKey.longHit count by userKey, over a window.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.vertigo.core.node.definition.DefinitionProvider
addDefinitionResourceConfigMethods inherited from interface io.vertigo.core.node.definition.SimpleDefinitionProvider
get
-
Constructor Details
-
RateLimitingMemStorePlugin
-
-
Method Details
-
provideDefinitions
public List<? extends io.vertigo.core.node.definition.Definition> provideDefinitions(io.vertigo.core.node.definition.DefinitionSpace definitionSpace) - Specified by:
provideDefinitionsin interfaceio.vertigo.core.node.definition.SimpleDefinitionProvider
-
getBanishInstant
Description copied from interface:RateLimitingStorePluginGet banish until instant.- Specified by:
getBanishInstantin interfaceRateLimitingStorePlugin- Parameters:
userKey- user key (like ip)- Returns:
- banish until instant.
-
touch
Description copied from interface:RateLimitingStorePluginHit count by userKey, over a window.- Specified by:
touchin interfaceRateLimitingStorePlugin- Parameters:
userKey- user key (like ip)incrBy- increment bywindowSeconds- window in seconds
-
extendsWindow
- Specified by:
extendsWindowin interfaceRateLimitingStorePlugin
-
remainingSeconds
Description copied from interface:RateLimitingStorePluginGet remaining seconds in window for a userKey.- Specified by:
remainingSecondsin interfaceRateLimitingStorePlugin- Parameters:
userKey- user key (like ip)
-
incrementBanishCounter
Description copied from interface:RateLimitingStorePluginPrepare banishment, increment and get banish counter.- Specified by:
incrementBanishCounterin interfaceRateLimitingStorePlugin- Parameters:
userKey- user key (like ip)maxBanishSeconds- max seconds counting banishment (each banish reset this time)- Returns:
- current banish counter
-
banishUntil
Description copied from interface:RateLimitingStorePluginSet banish until instant for a userKey.- Specified by:
banishUntilin interfaceRateLimitingStorePlugin- Parameters:
userKey- userKey user key (like ip)banishUntil- banish until instant
-
getFirstHitAgeSecond
Description copied from interface:RateLimitingStorePluginGet first hit age for a userKey.- Specified by:
getFirstHitAgeSecondin interfaceRateLimitingStorePlugin- Parameters:
userKey- userKey user key (like ip)- Returns:
- age in second (-1 if unknown)
-
cancelBanishment
Description copied from interface:RateLimitingStorePluginCancel banishment of a userkey.- Specified by:
cancelBanishmentin interfaceRateLimitingStorePlugin- Parameters:
userKey- user key to reset
-
cancelAllBanishments
public void cancelAllBanishments()Description copied from interface:RateLimitingStorePluginCancel all banishments.- Specified by:
cancelAllBanishmentsin interfaceRateLimitingStorePlugin
-
getBanishments
- Specified by:
getBanishmentsin interfaceRateLimitingStorePlugin- Returns:
- current banished userKey
-