MCPcopy Index your code
hub / github.com/Effect-TS/effect / make

Function make

packages/effect/src/internal/rateLimiter.ts:11–28  ·  view source on GitHub ↗
({
  algorithm = "token-bucket",
  interval,
  limit
}: RateLimiter.RateLimiter.Options)

Source from the content-addressed store, hash-verified

9
10/** @internal */
11export 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
30const tokenBucket = (limit: number, window: DurationInput): Effect.Effect<
31 RateLimiter.RateLimiter,

Callers

nothing calls this directly

Calls 2

fixedWindowFunction · 0.70
tokenBucketFunction · 0.70

Tested by

no test coverage detected