Μετάβαση στο περιεχόμενο

RateLimitBehaviorOptions

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

Defined in: packages/pipeline-rate-limit/src/interfaces/rate-limit-options.interface.ts:36

Per-handler (and constructor-default) options for RateLimitBehavior.

Tenant + caller scoped limit

const perUser = createPartitionedRateLimitKeyFactory(
(ctx) => ctx.items.get('userId') as string | undefined,
);
class CreateOrderHandler {
@pipeline.wrap({ kind: 'command' }, [RateLimitBehavior, {
keyFactory: perUser,
points: 1,
}])
async handle(command: CreateOrderCommand) {}
}

optional failOpen?: boolean

Defined in: packages/pipeline-rate-limit/src/interfaces/rate-limit-options.interface.ts:67

When the backing store itself errors (e.g. Redis is unreachable — distinct from a normal limit hit), allow the request through (true, default) or reject it (false). Fail-open favors availability; fail-closed favors strict protection.


optional keyFactory?: RateLimitKeyFactory

Defined in: packages/pipeline-rate-limit/src/interfaces/rate-limit-options.interface.ts:53

Builds the bucket key. Required whenever the behavior executes; there is no implicit shared bucket. Prefer createPartitionedRateLimitKeyFactory for tenant/caller-aware limits.


optional keyPrefix?: string

Defined in: packages/pipeline-rate-limit/src/interfaces/rate-limit-options.interface.ts:55

Optional prefix prepended to the key as "<prefix>:<key>".


optional limiter?: RateLimiterLike

Defined in: packages/pipeline-rate-limit/src/interfaces/rate-limit-options.interface.ts:60

Per-handler limiter override — use a stricter/looser limiter for specific handlers without changing the global one. Defaults to the injected limiter.


optional points?: number | RateLimitCostFactory

Defined in: packages/pipeline-rate-limit/src/interfaces/rate-limit-options.interface.ts:47

Points this request costs: a non-negative safe integer, or a RateLimitCostFactory computing it per request. 0 charges nothing: the limiter is not called and no key is built. Default 1.

One point per imported row

points: (ctx) => (ctx.request as ImportUsersCommand).rows.length