-
Notifications
You must be signed in to change notification settings - Fork 41
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
Update RedisCache and rate limit related libraries #1290
base: master
Are you sure you want to change the base?
Conversation
2b9af0b
to
e3d72a2
Compare
10144c4
to
1ffe770
Compare
The application test starts a timer on the curation queue. This timer is not cleaned up, which causes intermittent failures in the "Curation queue processing" unit tests. Disable the unit test.
1ffe770
to
d0160f4
Compare
f7150d5
to
99a9aa4
Compare
bin/www
Outdated
const cachingService = config.caching.service() | ||
await Promise.all([cachingService.initialize()]).catch(error => { | ||
logger.error('Error connecting to cachingService', error) | ||
process.exit(1) |
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.
Fail fast here when redis fails to connect during startup. In the event of this happens, we have the option to update configuration to use in-memory caching for deployment as a fallback. Another option is to increase the connection timeout. Currently, default value is used here, same as the original code. Any thoughts?
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.
Problem is that while you wait for connection, your service is not exposing any endpoint. How do you deal with the cloud probes ?
test/app.js
Outdated
}) | ||
|
||
it.skip('should initialize', done => { | ||
const app = Application(config, { |
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 starts several timers, one of which operates on the curation queue. The timers are not properly cleaned up and interfere with the curation unit tests. Disabled the test for now.
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.
can't you mock the timers ?
bin/www
Outdated
const cachingService = config.caching.service() | ||
await Promise.all([cachingService.initialize()]).catch(error => { | ||
logger.error('Error connecting to cachingService', error) | ||
process.exit(1) |
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.
Problem is that while you wait for connection, your service is not exposing any endpoint. How do you deal with the cloud probes ?
test/app.js
Outdated
}) | ||
|
||
it.skip('should initialize', done => { | ||
const app = Application(config, { |
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.
can't you mock the timers ?
debug: () => {}, | ||
error: () => {}, | ||
info: () => {} |
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.
Since it is static, why not setting those line 348 ?
@qtomlinson I am not familiar enough with the project to approve all the changes but we had a great discussion on the app startup. |
… middleware Restored the integration test code for app. The test itself is still disabled because createApp starts recursive timers, which interfere with other unit tests.
@ArnaudBuchholz Thanks so much for your feedback! I really enjoyed our discussion. |
fc59b7f
to
357f8fa
Compare
357f8fa
to
f101ef3
Compare
This PR addresses the upgrade of our Redis and rate-limiting libraries, which had breaking changes. The following are the specific modifications and improvements made:
Refactor Rate Limiting Logic to
ratelimit.js
ratelimit.js
module for better encapsulation and to facilitate unit testing.Reduced the number of Redis clients from three to one
Standardization of Rate Limiting Headers
standardHeaders
instead of legacy headers. This is a breaking change that may affect clients using the old rate-limit headers.Addition of Unit and Integration Tests