Type Alias RateLimiterFactorySettingsBase

RateLimiterFactorySettingsBase: {
    context?: IReadableContext;
    defaultErrorPolicy?: ErrorPolicy;
    enableAsyncTracking?: boolean;
    onlyError?: boolean;
    serde?: OneOrMore<ISerderRegister>;
    serdeTransformerName?: string;
    waitUntil?: WaitUntil;
}

Base configuration shared by all RateLimiterFactory variants.

IMPORT_PATH: "@daiso-tech/core/rate-limiter"

Type declaration

  • Optionalcontext?: IReadableContext

    You can pass IReadableContext that will be used by context-aware adapters.

    import { ExecutionContext } from "@daiso-tech/core/execution-context"
    import { NoOpExecutionContextAdapter } from "@daiso-tech/core/execution-context/no-op-execution-context-adapter"

    new ExecutionContext(new NoOpExecutionContextAdapter())
  • OptionaldefaultErrorPolicy?: ErrorPolicy

    You can set the default ErrorPolicy

    (_error: unknown) => true
    
  • OptionalenableAsyncTracking?: boolean

    If true, metric tracking will run asynchronously in the background and won't block the function utilizing the circuit breaker logic. This will only have effect if onlyError settings is true.

    true
    
  • OptionalonlyError?: boolean

    If true will only apply rate limiting when function errors and not when function is called.

    false
    
  • Optionalserde?: OneOrMore<ISerderRegister>

    You can pass an ISerderRegister instance to the RateLimiterFactory to register the rate limiter's serialization and deserialization logic for the provided adapter.

    import { Serde } from "@daiso-tech/core/serde";
    import { NoOpSerdeAdapter } from "@daiso-tech/core/serde/no-op-serde-adapter";

    new Serde(new NoOpSerdeAdapter())
  • OptionalserdeTransformerName?: string

    The serde transformer name used to identify rate-limiter serializers and deserializers when there are adapters with the same name.

    ""
    
  • OptionalwaitUntil?: WaitUntil

    You can pass the waitUntil function to handle background promises. This is required when working with environments like Cloudflare Workers or Vercel Functions to ensure tasks complete after the response is sent.

    import { defaultWaitUntil } from "@daiso-tech/core/utilities"