Byron / google-apis-rs

A binding and CLI generator for all Google APIs
http://byron.github.io/google-apis-rs
Other
1.01k stars 131 forks source link

Feature request: Request limiter #391

Closed elpiel closed 1 year ago

elpiel commented 1 year ago

I recently got an error while running a CLI with google Photos that I exceeded the rate limit.

It would be nice to have the option to set quote limits for the client. I don't know how many limits there are but from the error I can see 2: Read requests & Read requests per minute per user

Error: Bad Request: {"error":{"code":429,"details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","domain":"googleapis.com","metadata":{"consumer":"projects/832012397629","quota_limit":"ReadsPerMinutePerUser","quota_limit_value":"300","quota_location":"global","quota_metric":"photoslibrary.googleapis.com/read_requests","service":"photoslibrary.googleapis.com"},"reason":"RATE_LIMIT_EXCEEDED"},{"@type":"type.googleapis.com/google.rpc.Help","links":[{"description":"Request a higher quota limit.","url":"https://cloud.google.com/docs/quota#requesting_higher_quota"}]}],"message":"Quota exceeded for quota metric 'Read requests' and limit 'Read requests per minute per user' of service 'photoslibrary.googleapis.com' for consumer 'project_number:832012397629'.","status":"RESOURCE_EXHAUSTED"}}
Byron commented 1 year ago

Thanks for the suggestion.

Unfortunately doing so is out of scope of these crates, which only represent an existing API surface of the Google APIs as can be generated from their API descriptions. No other features sitting on top of that will be implemented here.

That said, such a request might be more suited for the produces of the Google APIs. Alternatively you can point out how parts of the API you want to use to handle quotas aren't usable or exposed through these crates, which is something that can be addressed.

Thanks for your understanding.

elpiel commented 1 year ago

I understand. Thanks anyway! Btw it's interesting that doing the requests sequentially (in a loop) does not trigger the limit, only if I join all futures together.