-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implement rateLimit configuration #84
Conversation
8d88a7f
to
c925bd6
Compare
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.
Looks good 🚀
Thread.sleep(500); | ||
String event3 = InngestFunctionTestHelpers.sendEvent(client, "test/rateLimit").getIds()[0]; | ||
|
||
Thread.sleep(2000); |
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.
Should we increase the duration similar to idempotency #85?
RateLimitedFunctionIntegrationTest > testFunctionIsRateLimited() FAILED
java.lang.ArrayIndexOutOfBoundsException: 0
at com.inngest.springbootdemo.EventRunsResponse.first(EventRunsResponse.java:14)
at com.inngest.springbootdemo.RateLimitedFunctionIntegrationTest.testFunctionIsRateLimited(RateLimitedFunctionIntegrationTest.java:32)
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.
good idea, increased the two 2000ms waits to 4000ms
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.
Adjusted all the times again based on https://www.inngest.com/docs/guides/rate-limiting#how-rate-limiting-works
Very similar to throttle implementation in #66
c925bd6
to
ba3587a
Compare
// Rate limit test function is limited to 2 over 6 seconds. Based on the simplistic description of GCRA in | ||
// https://www.inngest.com/docs/guides/rate-limiting#how-rate-limiting-works | ||
// we need to sleep at least 3 seconds here for the second event not to get rate limited |
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.
This test was buggy before instead of just being flaky. After reading the documentation at https://www.inngest.com/docs/guides/rate-limiting#how-rate-limiting-works, I adjusted the sleep times for the test to hopefully run more robustly.
// Sleep at least 6 seconds for the rate limit bucket to be completely cleared | ||
Thread.sleep(6000); | ||
|
||
// Rate limit should only allow the first 2 events to run |
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.
the function config was mismatched with this comment until now 😭
Summary
Add rateLimit configuration per https://github.com/inngest/inngest/blob/0ac11f2c312c066e517e53749052dd89fd2926ba/docs/SDK_SPEC.md?plain=1#L586-L606
Very similar to throttle implementation in #66
Checklist
Related