-
Notifications
You must be signed in to change notification settings - Fork 37
feat: added support for redis v5 #1710
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
base: main
Are you sure you want to change the base?
Conversation
Let's wait for the currencyJira card to be created. |
In v5, Redis moved “Isolation Pool” into RedisClientPool with a createClientPool export—but importing createClientPool throws “Not Found,” so the docs don’t match the package. Opened an issue in redis: redis/node-redis#2936 |
e28b5da
to
607a935
Compare
The new sentinel API is not working for me created an issue: redis/node-redis#2962 |
@@ -1,7 +1,7 @@ | |||
version: '2' | |||
services: | |||
redis: | |||
image: redis:5.0.14 | |||
image: redis:7.4.3 |
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 Redis Docker image has been updated to the latest version.
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.
MUA
@@ -111,6 +111,7 @@ | |||
"@opentelemetry/instrumentation": "0.50.0", | |||
"@opentelemetry/sdk-node": "^0.49.1", | |||
"@opentelemetry/sdk-trace-base": "^1.22.0", | |||
"@redis/client-v4": "npm:@redis/[email protected]", |
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 @redis/client package was introduced with Redis v4 (@redis/client v1). In Redis v5, the versioning of @redis/client was synchronized with Redis, meaning @redis/client v5 corresponds to Redis v5.
To improve the testing setup, I’ve specified @redis/client v4 (corresponding to Redis v4) instead of v1.
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.
"@redis/client-v4": "npm:@redis/[email protected]",
v4 = 1.6.0?
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.
v4 = 1.6.0?
In v4, the redis/client
was at version 1.6.x (see here). With v5, the client version was updated to v5.0 to align its versioning with Redis itself. For simplicity in testing, it is labeled as v4, and I have added a comment in the test file.
Additionally, for redis/client
, after version 1.6, the major version jumped directly to v5, with no official stable releases in between—only prerelease versions were published. See: https://www.npmjs.com/package/@redis/client?activeTab=versions
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.
Don't we have to add
@redis/client: 5.x
@redis/client-4: v1
?
So we test against all legacy package versions and the new releases?
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.
Yea. Make sense!. @redis/client is a direct dependency of the redis package, so it gets installed automatically along with it. However, for better readability and maintainability, I can explicitly include it as well.
@redis/client: v5.x
@redis/client-4: v1.x
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.
We also need it for currency?
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.
added
"redis-v3": "npm:redis@^3.1.2", | ||
"redis-v4": "npm:redis@^4.7.0", |
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 maintain tests for three versions of Redis, and each of these tests involves changes.
88b438a
to
10de7ff
Compare
As discussed the sentinel support will be added in a separate PR |
@@ -721,8 +771,12 @@ const globalAgent = require('../../../globalAgent'); | |||
span => expect(span.n).to.equal('node.http.server'), | |||
span => expect(span.data.http.method).to.equal('GET') | |||
]); | |||
// NOTE: v5 SCAN iterators yield batches of keys, enabling multi-key commands like MGET. | |||
// See: https://github.com/redis/node-redis/blob/master/docs/v4-to-v5.md#scan-iterators | |||
const expectedSpanCount = redisVersion === 'latest' ? 1 : 4; |
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.
QS: Could you please add an assertion for the batch property span.b
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.
In case of scanIterators. It's not a batched span. The comment is confusing I will update
await controls.clearIpcMessages(); | ||
}); | ||
|
||
it('should trace blocking commands', () => testBlockingCommand(controls, setupType)); |
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 don't understand this test. Blocking commands?
method: 'POST',
path: '/clearkeys'
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.
💁♀️
10de7ff
to
e221401
Compare
c0363e0
to
faf4476
Compare
Redis v5: Changes in this PR
Connection Termination
In Redis v5, the method
client.quit()
(orclient.QUIT
) has been deprecated and replaced byclient.close()
.Scan Iterator Behavior
Cluster Command Signature Change
In Redis v5, the method
cluster.multi().addCommand()
has an updated signature.isReadonly
), and the actual command array is passed as the third argument.Connection Pool
Redis v5 introduces a dedicated
RedisClientPool
class for managing connection pools.RedisClient
using an "Isolation Pool".Internal File Structure Changes
Redis v5 introduces a new internal structure for the package, requiring updates to how we reference and mock internal modules.
Package Versioning Alignment
The
@redis/client
package versioning now aligns with the Redis server version:@redis/client
was versioned as 1.x.@redis/client
is now versioned as 5.x.Additional Update
Tasks
References
Release notes: https://github.com/redis/node-redis/releases/tag/redis%405.0.0
Migration guide: https://github.com/redis/node-redis/blob/master/docs/v4-to-v5.md
Ref: https://jsw.ibm.com/browse/INSTA-35744