netsuitephp / netsuite-php

NetSuite PHP API Client with namespaces and autoloading
Other
189 stars 85 forks source link

Add retry feature when exceeding NetSuite's concurrent Request Limit #133

Closed rhys-hanrahan closed 1 year ago

rhys-hanrahan commented 2 years ago

I am using this library in an application that loads a lot of different CRM records in parallel. When the application starts, I often hit the concurrent request limit in the app, causing errors for the user. I felt the best way to handle this was to check for this particular exception being thrown, wait some period of time, and try again.

I felt that this would be a useful feature for others and it made sense to add this into the library itself, instead of trying to add wrappers around all the different API calls that this library supports.

This pull request adds the retry functionality, with the following features. Any feedback would be appreciated.

rhys-hanrahan commented 2 years ago

Just a note that after further testing, I found retries working more reliably after hitting concurrency limit if I changed the settings to:

I haven't updated the default settings in this PR as those numbers are a hit more aggressive, and I did have solid improvements with 1s x3. I just noticed that in some cases even after 3x retries, I was still seeing failures.

jrebs commented 1 year ago

Sorry for the slow response, but it was deliberated and agreed that this is outside scope for this library. Appreciate the PR.