Comments (5)
Hi Malc
I'm happy for this to go into the library. I've been thinking a little how to manage this myself as my app needs to do a rather extensive sync when the company is first linked (and heaven forbid Xero provides invoice line items in a complete invoice listing).
The API should already raise Xeroizer::OAuth::RateLimitExceeded exceptions when Xero does however, I would like to pre-emptively prevent these from occurring in the first place. I was going to implement this in my app as an evented, asynchronous queue that on receiving an exception, pauses until it is likely to be able to succeed again.
The biggest issue I see to implementing this solution in Xeroizer is the API would probably have to change significantly to allow for asynchronous-based messaging and callbacks and I'm not sure this would be the best thing for the most common use-cases of Xeroizer.
I'm happy to listen to other ideas though.
from xeroizer.
Our current thoughts around 'the simplest thing that will work' is to cache 'last request', then microsleep until 1 second has expired from that time on the next call if required.
Would like to have this as a switch on the gateway object, e.g. @gateway.governor = true
as it may not be required all the time, and default to false
.
At the moment we're doing sleep 1
in our app for each call, which is, well ... less than satisfactory.
from xeroizer.
Well, the rate limiter actually allows up to 60 requests per minute, so maybe implementing some type of sliding window that only allows 60 requests per second and then pauses for up to a second (if required) before allowing more requests. I don't think it is really worthwhile trying to keep track of the 1,000 requests per day.
From a simplicity point of view, maybe if we just catch the rate exceptions in the HTTP library and, if one is raised we wait for x and then auto-retry transparently to the client.
from xeroizer.
Agree re daily limit.
Also agree re catching rate limit exceptions, will implement next week and send a push.
Malc
from xeroizer.
No way to attach a pull request to an existing issue, so moving to #14
from xeroizer.
Related Issues (20)
- Question: Does Xeroizer support OAuth 2? HOT 2
- `.sent_to_contact` on Invoices is undefined HOT 3
- Update the readme/documentation to include Oauth2Application HOT 2
- Xero Deprecation Notice - OAuth 1.0a HOT 1
- Timeout option not set correctly on OAuth 2 client HOT 3
- invoice.save returns false but invoice.errors is empty HOT 15
- New gem release? HOT 6
- How to get all the Items from Xero account HOT 1
- NameError: uninitialized constant Xeroizer::OAuth2Application HOT 4
- Double raise for expired tokens? HOT 2
- GET ERROR WHE do any object.save HOT 2
- trying to run tests as a developer... HOT 5
- syntax error, unexpected ',' in branding_theme.rb HOT 1
- Line Amount can not explicity be set to 0.00 if there is a discount
- Missing require somewhere: "uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState" when used outside of Rails HOT 3
- AuthorizationUnsuccessful error HOT 2
- ApiExceptions result in parse error
- Saving Quotes
- BankAccount Model Not Available?
- How to revoke token / delete current_connection 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 xeroizer.