Skip to content

Commit 61b9b92

Browse files
committed
Docs
1 parent 458bc8d commit 61b9b92

File tree

2 files changed

+23
-155
lines changed

2 files changed

+23
-155
lines changed

cursor-rules/152-ox-utility-functions.mdc

Lines changed: 0 additions & 132 deletions
This file was deleted.

cursor-rules/162-ox-rate-limiting.mdc

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@ Apply rate limiting to prevent system overload. Choose appropriate algorithms ba
99

1010
**Fixed window rate limiting:**
1111
```scala
12-
val rateLimiter = RateLimiter.fixedWindow(
13-
permits = 100, // 100 requests
14-
window = 1.minute // per minute
15-
)
16-
17-
rateLimiter.runBlocking {
18-
callExternalAPI()
19-
}
12+
val rateLimiter = RateLimiter.fixedWindow(
13+
permits = 100, // 100 requests
14+
window = 1.minute // per minute
15+
)
16+
17+
rateLimiter.runBlocking {
18+
callExternalAPI()
19+
}
2020
```
2121

2222
**Token bucket for burst handling:**
2323
```scala
24-
val rateLimiter = RateLimiter.tokenBucket(
25-
capacity = 50, // 50 tokens max
26-
refillRate = 10 // 10 tokens per second
27-
)
24+
val rateLimiter = RateLimiter.tokenBucket(
25+
capacity = 50, // 50 tokens max
26+
refillRate = 10 // 10 tokens per second
27+
)
2828

29-
// Allows bursts up to 50, then 10/second sustained
30-
rateLimiter.runBlocking {
31-
processRequest()
32-
}
29+
// Allows bursts up to 50, then 10/second sustained
30+
rateLimiter.runBlocking {
31+
processRequest()
32+
}
3333
```
3434

3535
**Sliding window for smooth rate limiting:**
3636
```scala
37-
val rateLimiter = RateLimiter.slidingWindow(
38-
permits = 1000, // 1000 requests
39-
window = 1.hour // per hour
40-
)
37+
val rateLimiter = RateLimiter.slidingWindow(
38+
permits = 1000, // 1000 requests
39+
window = 1.hour // per hour
40+
)
4141

42-
rateLimiter.runBlocking {
43-
heavyComputation()
44-
}
42+
rateLimiter.runBlocking {
43+
heavyComputation()
44+
}
4545
```
4646

4747
**Algorithm selection:**

0 commit comments

Comments
 (0)