Coder Social home page Coder Social logo

API rate limits about xeroizer HOT 5 CLOSED

waynerobinson avatar waynerobinson commented on August 17, 2024
API rate limits

from xeroizer.

Comments (5)

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

malclocke avatar malclocke commented on August 17, 2024

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.

waynerobinson avatar waynerobinson commented on August 17, 2024

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.

malclocke avatar malclocke commented on August 17, 2024

Agree re daily limit.

Also agree re catching rate limit exceptions, will implement next week and send a push.

Malc

from xeroizer.

malclocke avatar malclocke commented on August 17, 2024

No way to attach a pull request to an existing issue, so moving to #14

from xeroizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.