-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate redis rate limiter with saas connectors #1433
Integrate redis rate limiter with saas connectors #1433
Conversation
@adamsachs n @galvana, I think this is in a pretty good place to get some feedback. I'll also add some comments for some things which I think need more attention. |
src/fides/api/ops/service/connectors/saas/authenticated_client.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think everything here looks really good @earmenda. i really like how you've brought the rate limiter into the saas framework - it's super clean and easy to follow.
in the application code, only some minor comments asking for a bit of clarification on certain points.
i do think you could build on your test updates a bit further. particularly, i'd like to see some
"end-to-end" coverage actually evaluating that the rate limiter config is correctly making its way into the saas execution framework (see comment on L103 saas_config.py
). happy to touch base offline if what i mean by that isn't clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamsachs thanks for your in-depth review. I addressed most of the things discussed but there's a couple things I'm putting some thought into still. Let me know what you think!
sorry about the deleted comment, was trying to understand if that's why I couldn't resolve all conversations. |
@adamsachs @galvana I made some major changes since we reviewed this last week. As I was writing documentation I realized that there was some confusing user experience with my original idea. I decided that if a rate limit config is set on the client config AND at the request endpoint then it should work as an override. Some reasons for this:
I also decided to redo the refactoring that I had undone because I wanted to simplify the SaasConnector:
AuthenticatedClient
Sorry for the refactoring to this PR but it was closely tied to the implementation of this feature. I am pretty comfortable merging this now after review. Documentation is also done! |
@conceptualshark do you have some time to take a look at new docs I wrote for saas connector rate limiting? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall i like all the updates @earmenda! the client code is more transparent now IMO, and i like the UX you've enabled with rate limiter overrides.
just some minor comments that i don't think are blockers, so I'm approving. but i do think they're worth taking a look at and possibly addressing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest changes look to address what i mentioned really nicely, thanks for that.
overall, this looks great - let's get it merged now!
@adamsachs Thanks again for the thorough review, your comments have been really helpful. |
Closes #1221
Code Changes
RateLimitPeriod
andRateLimitConfig
to schema package as the model to be used by our connector configrate_limits
toSaaSRequest
andSaaSConfig
modelsRateLimiter
implementation to work with a list ofRateLimitRequest
. This means that one call tolimit
can respect multiple limits. Because of this we now decrement counts when a limit is breached.AuthenticatedClient
to take inSaasRequest
as parameterbuild_rate_limit_requests
inAuthenticatedClient
to buildRateLimitRequest
based on configRateLimiter.limit
withinAuthenticatedClient
Steps to Confirm
Pre-Merge Checklist
CHANGELOG.md
Description Of Changes
Model and integration changes for rate limiter from #1189.
We decided to allow the rate limiter to allow multiple limits which meant changing current limiter implementation. If we want to respect multiple limits simultaneously then it is not enough to just increment the rate limiter as it did before. If one limit succeeds and another fails, then the rate limiter should decrement the succeeding limit as a call will not be made.
One place where I could see us having further discussion is whether request level limits should override or add on to connector rate limits. This is implemented in
build_rate_limit_requests
.