# IRateLimiter

`interface` in `types` · v0.16.0

<https://seedcord.org/docs/packages/types/0.16.0/interfaces/irate-limiter>

Sliding-window rate limiting keyed by caller-built strings, available as `core.rateLimiter`. It
saves its counts in `config.kv`.

```ts
interface IRateLimiter
```

## Methods

### charge

```ts
charge(
    key: string,
    window: RateLimitWindow
): Promise<RateLimitResult>
```

Records a use of `key` if the window has a free slot. Charges on one key run one at a time in
this process.

### peek

```ts
peek(
    key: string,
    window: RateLimitWindow
): Promise<RateLimitResult>
```

Reports `key`'s limited state without recording a use.

The read half of a peek-then-commit. The `Cooldown` gate peeks in its check and charges in its
commit, so a refusal elsewhere in the gate set never burns the slot.

### reset

```ts
reset(key: string): Promise<void>
```

Clears `key`'s recorded uses.
