IF Commons GitHub

logical/layers/rate-limited

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-anyfs-middleware FR-005

The rate-limited layer: at most a number of operations in an interval, by a token bucket that refills with the clock the caller gives. An operation over the limit waits through the sleep of the clock and is then made; the limit never fails an operation.

import { rateLimited } from "./rate-limited.ts";
// const store = rateLimited(inner, { operations: 10, intervalMs: 1000 }, clock)

Source: commons/anyfs/src/logical/layers/rate-limited.ts

1 of 2 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

RateLimittypeno test imports it
type RateLimit = { readonly operations: number; readonly intervalMs: number };

How many operations in how many milliseconds.

rateLimitedfunction
function rateLimited<C extends Capability>(store: Store<C>, limit: RateLimit, clock: Clock): Store<Carried<C>>

A store that makes at most the operations of the limit in each interval, and keeps the capabilities of its argument.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.