Replies: 2 comments
-
When developing, to get a sense of safety PoeApi.setMockMode() // or .setBatch()
const items = PoeApi.search('Ritual', { type: 'Ring', mods: ['All T1 Harvest Mods lul', 'Never gonna see these together again'] })
console.log(PoeApi.mockExecute())
/**
* Expected # of requests: 127
* Request breakdown:
* .character: {
* requests: 1,
* .items: {
* requests: 1,
* .item: {
* requests: 7,
* .search {
* requests: 1
* }
* }
**/ |
Beta Was this translation helpful? Give feedback.
-
Built-in rate limiting is definitely something I'd like to have as an option in the library. Great code snippets, should definitely come in handy! As a disclaimer, I'm not terribly familiar with all of this rate limit stuff, so I might get some things wrong or ask stupid questions. Do you have an idea how It might be easier to write our own implementation which supports multiple buckets for a single rate limiting policy. That way we could make sure that we comply with every rule by checking if each bucket has at least one token. As a bonus we'd avoid using callbacks or promisifying third party methods. I don't think token buckets are too difficult to write. Scheduling requests would definitely be very useful, and as you mentioned, there should be a configurable maximum timeout before the rate limiter throws an error. In the past I used bottleneck. It has built-in scheduling of requests, which I quite like. I thought I could use an instance of
I'd say that if the rate limiter says it's fine to make a request, the request should be made without delay/minimum execution time.
Would be nice to have, but I personally don't think it's a necessity. Might add some weird complexity to return values, I don't think you can easily add information that is immediately accessible to promises (if you can, enlighten me). Do you think the current state should be taken into consideration somehow? I don't know if the state we get in the response should be synced with the available tokens in the rate limiters. I'm asking because the state could always be different from the amount of tokens internally, because other instances could hit the API and the internal token buckets would never know (manual browsing, other tools, ...). |
Beta Was this translation helpful? Give feedback.
-
Felt like starting a discussion to make the api wrapper more fun to use. One thing would be (opt-out) ratelimiting.
I searched for the topics
ratelimit
,limiter
, andthrottle
on npmjs.com. Clicked on a few, and this one seemed the most simple, though its more callback-y than promise-y.https://github.com/jhurliman/node-rate-limiter#usage
I also started writing something to give a little more context to the poe ratelimit headers:
A few things to think about regarding ergonomics of making this nice for the developer:
My gut feeling is that including a ratelimiter that blocks on await, with an optional timeout, would improve ergonomics.
Beta Was this translation helpful? Give feedback.
All reactions