Comments (5)
I totally agree with to you. The api limit check is still not optimized
from shopify.
Do you have any idea to deal with this problem? @Art3miX
from shopify.
I didn't use this lib in the end and can't do a pull request.
But yea, its pretty easy to change it.
in client.php :
getCallLimit should return the exact number of request left, so we take the bucket size and reduce the amount of calls we already did :
return $this->call_bucket - $this->call_limit;
callLimitReached should return true if 1 or less requests left (just in case we leave extra 1 request in bucket).
return $this->getCallLimit() <= 1;
And the sleep should be changed to 1 second, because shopify give us 2 requests each second, so we wait 1 second and we get extra 2 requests, this will ensure us we only wait the minimum time needed between requests.
in request function:
if ($this->rate_limit && self::$delay_next_call) {
// Sleep a random amount of time to help prevent bucket overflow.
usleep(1 * 1000000);
}
Sorry for this poor answer, but this should get you going (unless i forgot something), i'm sure someone can find the time to do a pull request.
from shopify.
Ok. I think it's great idea. But how can I do it inside this lib without processing in the request method?
from shopify.
I found a solve in the internet by reading header named Retry-After, but I don't test it.
from shopify.
Related Issues (20)
- Public App access_token HMAC doesn't validate per Shopify specification
- syntax error, unexpected '$object' (T_VARIABLE)
- Composer installation does not work HOT 2
- What is the license of this code? HOT 1
- Create realeases HOT 1
- PHP Error: Call to a member function getBody() on null in /vendor/donutdan4114/shopify/src/Shopify/Client.php on line 110
- Documentation can be more useful
- Calling GraphQL endpoint throws exception on API limit checks
- Webhooks Invalid Secret HOT 2
- Shopify API version depreciated in 2020 HOT 13
- Passing a limit over 250 to getResources() causes error
- Request failed when creating product with image url - even though product is created HOT 2
- Add support for Guzzle 7 HOT 2
- Add new Exception Type for missing scopes
- Shopify\ShopifyMissingScopesException: Missing required scope in Shopify\Client->handleScopeException
- Allow for -optionally - pulling metafields for Products HOT 2
- Stable release HOT 6
- Embed App Issue
- question: Can this be used to create an order+payment? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopify.