Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Commercetools Async Pool Laravel Package

bestit/commercetools-async-pool

Laravel-friendly async pool for commercetools PHP SDK requests. Schedule, batch, and execute API calls concurrently with configurable limits, retries, and callbacks, helping speed up imports, sync jobs, and background processing while keeping resource usage under control.

View on GitHub
Deep Wiki
Context7

commercetools-async-pool

Batch-Processing of a pool asynchronous commercetools requests.

Introdction

Commercetools suggests that you use asynchronous requests instead of sequential ones but the PHP SDK makes it not very easy:

  1. Promises for Client::executeAsync works on the raw guzzle response, not the "requested object".
  2. Guzzle promise-chaining/forwarding and the AbstractApiResponse from commercetools are not compatible.

So i created a helping pool of async requests. Please review the following information.

Installation

composer require bestit/commercetools-async-pool

API and Usage

$pool = new Pool($this->getClient());

$pool->addPromise(ProductTypeByIdGetRequest::ofId('example')).then(
    // Success
    function(ProductType $productType) use ($userdata) {          
        echo $productType->getId();
    },
    // optional error callback
    function(ErrorResponse $error) {
        echo $error->getStatusCode();    
    }
);
//.then(/* chained callbacks */)
//.then()
// ....

// Gets flushed automatically, if we overflow the tick rate from the constructor.
$pool->flush();

But beware, do not forget that the callbacks are happening asynchronous! That is no sequential PHP anymore!

Future

  • More Unittests
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor