({
algorithm = "token-bucket",
interval,
limit
}: RateLimiter.RateLimiter.Options)
| 9 | |
| 10 | /** @internal */ |
| 11 | export const make = ({ |
| 12 | algorithm = "token-bucket", |
| 13 | interval, |
| 14 | limit |
| 15 | }: RateLimiter.RateLimiter.Options): Effect.Effect< |
| 16 | RateLimiter.RateLimiter, |
| 17 | never, |
| 18 | Scope.Scope |
| 19 | > => { |
| 20 | switch (algorithm) { |
| 21 | case "fixed-window": { |
| 22 | return fixedWindow(limit, interval) |
| 23 | } |
| 24 | case "token-bucket": { |
| 25 | return tokenBucket(limit, interval) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | const tokenBucket = (limit: number, window: DurationInput): Effect.Effect< |
| 31 | RateLimiter.RateLimiter, |
nothing calls this directly
no test coverage detected