Skip to content

sdk-middleware-queue

Middleware to throttle concurrent request to a certain limit. Useful to reduce concurrent HTTP requests.

⚠️ In Maintenance Mode ⚠️

This package has been replaced by the TypeScript SDK is in maintenance mode as such this tool will no longer receive new features or bug fixes.

We recommend to use the TypeScript SDK for any new implementation and plan migrating to it.

Install

Node.js

npm install --save @commercetools/sdk-middleware-queue

Browser

<script src="https://unpkg.com/@commercetools/sdk-middleware-queue/dist/commercetools-sdk-middleware-queue.umd.min.js"></script>
<script>
  // global: CommercetoolsSdkMiddlewareQueue
</script>

createQueueMiddleware(options)

Creates a middleware to handle concurrent requests.

Named arguments (options)

  1. concurrency (Number): the max number of concurrent requests (default 20)

Usage example

import { createClient } from '@commercetools/sdk-client'
import { createQueueMiddleware } from '@commercetools/sdk-middleware-queue'

const client = createClient({
  middlewares: [
    createQueueMiddleware({
      concurrency: 5,
    }),
  ],
})