Apache OpenDAL™ - v0.49.2
    Preparing search index...

    Class ThrottleLayer

    Throttle layer

    Add a bandwidth rate limiter to the underlying services.

    Throttle

    There are several algorithms when it come to rate limiting techniques. This throttle layer uses Generic Cell Rate Algorithm (GCRA) provided by Governor. By setting the bandwidth and burst, we can control the byte flow rate of underlying services.

    Note

    When setting the ThrottleLayer, always consider the largest possible operation size as the burst size, as the burst size should be larger than any possible byte length to allow it to pass through.

    Examples

    This example limits bandwidth to 10 KiB/s and burst size to 10 MiB.

    const op = new Operator("fs", { root: "/tmp" })

    const throttle = new ThrottleLayer(10 * 1024, 10000 * 1024);
    op.layer(throttle.build());
    Index

    Constructors

    Methods

    Constructors

    • Create a new ThrottleLayer with given bandwidth and burst.

      Arguments

      • bandwidth: the maximum number of bytes allowed to pass through per second.
      • burst: the maximum number of bytes allowed to pass through at once.

      Notes

      Validation (bandwidth and burst must be greater than 0) is handled by the Rust core layer.

      Parameters

      • bandwidth: number
      • burst: number

      Returns ThrottleLayer

    Methods