本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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());
}