-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: Allow for pubsub connections to optionally be taken from pool #2869
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: master
Are you sure you want to change the base?
Conversation
vtermanis
commented
Jan 18, 2024
- Suggestion for Proposal: Optionally allow for pubsub connections to be tracked in pool #2867
- Only applicable to non-cluster client
- Question: Should it apply to all client types?
Only the RE Tests suite fails - it's not able to find an (internal?) docker image. I believe there's nothing I can do about that. |
- After use, they are removed from the pool - Only applicable to non-cluster client
53d5a1a
to
49e1dc8
Compare
@ofekshenawa thank you for taking a look. Are you sure it's a breaking change? The way I've tried to write should mean that both from a behaviour and performance perspective it behaves as before unless the new configuration flag is explicitly set. |
This pull request is marked stale. It will be closed in 30 days if it is not updated. |
@vtermanis thank you for your contribution. What will happen if we exhaust the pool with pub-sub connections, since they are not reusable with resp2? |
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.
PR Overview
This PR introduces the ability to have PubSub connections optionally taken from the connection pool for non-cluster clients. Key changes include:
- Updated tests in pubsub_test.go to verify the behavior when using or not using pool connections.
- Modifications in redis.go and pubsub.go to branch connection handling based on the new PubsubFromPool option.
- Addition of the PubsubFromPool flag in options.go with accompanying documentation.
Reviewed Changes
File | Description |
---|---|
pubsub_test.go | Adds new tests verifying both pool and non-pool connection behavior |
redis.go | Implements connection handling for PubSub based on the new option |
options.go | Introduces PubsubFromPool flag with explanatory comments |
pubsub.go | Adjusts connection function types to support pool-based usage |
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
pubsub_test.go:592
- [nitpick] A deferred call to pubsub.Close() already exists, making this explicit call potentially redundant. Consider removing one of the closures or ensuring that multiple calls to Close() are idempotent.
pubsub.Close()
c.pubsubCloseConn = func(conn *pool.Conn) error { | ||
c.removeConn(context.TODO(), conn, nil) |
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.
[nitpick] Using context.TODO() here may bypass important context propagation for error handling. Consider refactoring to pass a proper context if available.
c.pubsubCloseConn = func(conn *pool.Conn) error { | |
c.removeConn(context.TODO(), conn, nil) | |
c.pubsubCloseConn = func(ctx context.Context, conn *pool.Conn) error { | |
c.removeConn(ctx, conn, nil) |
Copilot uses AI. Check for mistakes.
@ndyakov - this should be no different to exhausting the pool with non-pubsub connections, I believe.
For both 1.iii & 2.iii, if a connection is closed instead of being returned for re-use, a new connection can be created again, within the total pool limit. |