Commit 19f3bbe 1 parent 129f397 commit 19f3bbe Copy full SHA for 19f3bbe
File tree 1 file changed +0
-24
lines changed
examples/src/test/scala/ox/ratelimiter/test
1 file changed +0
-24
lines changed Original file line number Diff line number Diff line change @@ -30,27 +30,3 @@ class RateLimiterTest extends AnyFlatSpec with Matchers with Eventually with Int
30
30
}
31
31
}
32
32
33
- it should " maintain the rate limit in all time windows" in {
34
- RateLimiter .withRateLimiter(10 , 1 .second) { rateLimiter =>
35
- val complete = new AtomicReference (Vector .empty[Long ])
36
- for (i <- 1 to 20 ) {
37
- rateLimiter.runLimited {
38
- println(s " ${LocalTime .now()} Running $i" )
39
- complete.updateAndGet(_ :+ System .currentTimeMillis())
40
- }
41
- Thread .sleep(100 )
42
- }
43
-
44
- eventually {
45
- complete.get() should have size (20 )
46
-
47
- // the spacing should be preserved. In a token bucket algorithm, at some point the bucket would refill and
48
- // all pending futures would be run. In a windowed algorithm, the spacings are preserved.
49
- val secondHalf = complete.get().slice(10 , 20 )
50
- secondHalf.zip(secondHalf.tail).map { case (p, n) => n - p }.foreach { d =>
51
- d should be <= (150L )
52
- d should be >= (50L )
53
- }
54
- }
55
- }
56
- }
You can’t perform that action at this time.
0 commit comments