当前位置: 首页>>代码示例>>Java>>正文


Java RequestLimitRule.of方法代码示例

本文整理汇总了Java中es.moki.ratelimitj.core.limiter.request.RequestLimitRule.of方法的典型用法代码示例。如果您正苦于以下问题:Java RequestLimitRule.of方法的具体用法?Java RequestLimitRule.of怎么用?Java RequestLimitRule.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在es.moki.ratelimitj.core.limiter.request.RequestLimitRule的用法示例。


在下文中一共展示了RequestLimitRule.of方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldReturnTheSameInstanceForSameRules

import es.moki.ratelimitj.core.limiter.request.RequestLimitRule; //导入方法依赖的package包/类
@Test
void shouldReturnTheSameInstanceForSameRules() {

    RequestLimitRule rule1 = RequestLimitRule.of(1, TimeUnit.MINUTES, 10);
    RequestRateLimiter rateLimiter1 = factory.getInstance(ImmutableSet.of(rule1));

    RequestLimitRule rule2 = RequestLimitRule.of(1, TimeUnit.MINUTES, 10);
    RequestRateLimiter rateLimiter2 = factory.getInstance(ImmutableSet.of(rule2));

    assertThat(rateLimiter1).isSameAs(rateLimiter2);
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:12,代码来源:InMemoryRateLimiterFactoryTest.java

示例2: shouldReturnTheSameInstanceForSameSetOfRules

import es.moki.ratelimitj.core.limiter.request.RequestLimitRule; //导入方法依赖的package包/类
@Test
void shouldReturnTheSameInstanceForSameSetOfRules() {

    RequestLimitRule rule1a = RequestLimitRule.of(1, TimeUnit.MINUTES, 10);
    RequestLimitRule rule1b = RequestLimitRule.of(1, TimeUnit.HOURS, 100);
    RequestRateLimiter rateLimiter1 = factory.getInstance(ImmutableSet.of(rule1a, rule1b));

    RequestLimitRule rule2a = RequestLimitRule.of(1, TimeUnit.MINUTES, 10);
    RequestLimitRule rule2b = RequestLimitRule.of(1, TimeUnit.HOURS, 100);
    RequestRateLimiter rateLimiter2 = factory.getInstance(ImmutableSet.of(rule2a, rule2b));

    assertThat(rateLimiter1).isSameAs(rateLimiter2);
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:14,代码来源:InMemoryRateLimiterFactoryTest.java

示例3: shouldNotReturnTheSameInstanceForSameRules

import es.moki.ratelimitj.core.limiter.request.RequestLimitRule; //导入方法依赖的package包/类
@Test
void shouldNotReturnTheSameInstanceForSameRules() {

    RequestLimitRule rule1 = RequestLimitRule.of(1, TimeUnit.MINUTES, 22);
    RequestRateLimiter rateLimiter1 = factory.getInstance(ImmutableSet.of(rule1));

    RequestLimitRule rule2 = RequestLimitRule.of(1, TimeUnit.MINUTES, 33);
    RequestRateLimiter rateLimiter2 = factory.getInstance(ImmutableSet.of(rule2));

    assertThat(rateLimiter1).isNotSameAs(rateLimiter2);
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:12,代码来源:InMemoryRateLimiterFactoryTest.java

示例4: toLimitRule

import es.moki.ratelimitj.core.limiter.request.RequestLimitRule; //导入方法依赖的package包/类
private RequestLimitRule toLimitRule(Rate rate) {
    return RequestLimitRule.of(rate.duration(), rate.timeUnit(), rate.limit());
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:4,代码来源:RateLimit429EnforcerFilter.java


注:本文中的es.moki.ratelimitj.core.limiter.request.RequestLimitRule.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。