-
Notifications
You must be signed in to change notification settings - Fork 551
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
Initial implementation of RESP3 #757
Conversation
If we're making breaking changes here, we should also consider renaming the |
I'm unsure about the breaking changes. I think it's probably reasonable given the plainly wrong names for some of the the data types, but we should probably have a new name for the variant entirely rather than make confusion worse for users of this lib by changing the meaning of |
Thanks for the PR, btw. This will take some time to review as I come up to speed on RESP3 but eager to see how this turns out as we definitely need the functionality. |
hello @jaymell, now it passes all tests for both resp2 and resp3. |
@nihohit Since you also have interest in RESP3, would you mind reviewing these changes? I'm tied up with trying to get the async-cluster changes merged so would appreciate another pair of eyes if possible here. 🙏 |
@jaymell will do! |
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.
Very impressive work all around! And as far as I see, the parsing logic is great :)
Most of the comments involved code duplication, that I believe can be easily be reduced. From what I see, the main issues are:
- the async clients are missing the handling of push messages
- In general, the
execute_push_messages
are empty. - The case where the user requests RESP 3 but the server doesn't provide it needs to be handled.
Please ping me here or via my email if I can help with advancing this PR.
@altanozlu With renewed apologies for the continued delay, I'm about ready to approve this, but my bigger concern is what comes next. I'm thinking we probably shouldn't release this as-is without addressing the other items on #749, so as mentioned previously I am reluctant to put this on main branch at this point. Any thoughts on the remaining items? I'm thinking (without having given it enough thought, honestly) that we could potentially defer the streamed types to a later release, but I think at a minimum we should have functional Push handling in place before this is releasable. |
I think it's ok to wait until dealing with push messages is done. @nihohit i think to remove execute_push_message and make caching handler more exposed. Because currently other than invalidate message it's not going to bu used. |
what's the caching handler? |
Caching Handler is just a trait with get/key/remove,I think users don't need to handle push messages explicitly but a channel could be added later on. There is only |
So how will the user receive and use the caching handler? Will they implement the trait and then set the object somewhere? |
only thing they can do is provide cache key(which decides cache it or don't) and cache handler 'll handle it. The library can offer some default implementations(e.g. cached crate). |
Oh, I'm sorry, I completely misunderstood the context. You're talking about client side caching, right? :) |
I agree and execute_push_message is not a solution for this, a channel with size would be better for this. What do you think @jaymell ? If user provides an option, library can send push messages to it. |
I'm not clear on anything related to caching at this point so might be missing something, but a few thoughts:
|
@altanozlu please retarget the PR to the |
sure i think it's ready to merge into resp3 |
@altanozlu One final request before I merge. Can you clean up the top-level comment and provide something better for the commit message? 🙏 Thanks! |
Is it ok now ? I think |
Thanks @altanozlu. I took the liberty of removing the "resolves" line from the description -- I think we should keep these open until we merge this to to main, ideally with most/all of the remaining RESP3 TODO items. Thanks again for the great work! |
Adapted to this repo from work by @altanozlu. redis-rs#757
Adapted to this repo from work by @altanozlu. redis-rs#757
Adapted to this repo from work by @altanozlu. redis-rs#757
* Initial implementation of RESP3 (redis-rs#757) These changes implement all RESP3 types (excluding streamed types). RESP3 can be enabled per connection by adding `?resp3=true` to connection uri. It currently supports PubSub as RESP2 PubSub support in library, but in future PRs it'll support handling normal commands and PubSub messages in one connection. Only `num-bigint` is added as dependency to support `BigNumber` type. Changes made in support of redis-rs#329 and redis-rs#749 * Add RESP3 support to cluster connections. (redis-rs#1001) * Resp3 Push Management (redis-rs#898) * squash! * oops! * test invalidation in cluster && introduce client tracking options * introduce basic PubSub functionality to MultiplexedConnection and make tokio sender unbounded channel * fix tests & linter, make PushSender::Tokio as aio feature only * add resp3 to ci branches and fix cluster client tracking option * test dropping and update ci yml * remove unsubscribe fn and introduce unsubscribing by dropping receiver. * fix tests because RedisJson returns responses in an array when it's resp3 * override redisjson cache (it's a temp solution) * add -skip test_module to RESP3 testing and upgrade redis 6.2.4 to 6.2.13 * test json modules with RESP3 and get json fix from main * in redis v7 RedisJson is different with Resp3 🤔 * Implement Pub/Sub in Async Cluster & fmt & remove usage of is_err_and(stable only after v1.70) * don't use sharded pub/sub with redis v6 * use REDIS_VERSION in env instead of using HELLO command to fetch redis version * oops * fix linter * fix fmt and remove benchmark from CI * simplify PushManager and add tokio as non-optional dependency. * get fixes from 220c6a9 * use --test-threads=1 * override redisjson cache (it's a temp solution) * remove get_push_manager from traits & remove push manager from aio::Connection * remove client_tracking_options * remove 0.21.x from rust.yml * add tests for pushmanager * format & move push_info into a variable * change tests according to comments. * apply 6.2.4 changes && fmt * try to fix * remove con_addr & remove pub/sub support in cluster connections * add disconnection handling to sync, mpx, cm && test it * remove push_manager argument from connection creation * better docs * add has_reply function to PushKind * remove no response command support in mpx since it's not used in mpx pub/sub * apply changes from redis-rs#994 * fix tests * Use enum instead of boolean for RESP version. (redis-rs#1012) Since there's a discussion starting about what might become RESP4, this PR will make it easier to add more RESP versions in the future. * Add lock file to keep MSRV constant. (redis-rs#1039) * [opt] preallocate buffer for evalsha in `Script` (redis-rs#1044) * Cluster: fix read from replica & missing slots. (redis-rs#965) * Cluster SlotMap: Allow missing slots. The cluster can still operate when some slots don't have coverage, so there's no reason that the connection won't work. Requests that should be routed to missing slots will be forwarded to a random node. * Fix SlotAddrs not holding all replicas. This change fixes 2 issues - 1. Since SlotAddrs saves at most 1 replica (or none, if `read_from_replica` is false), it means that when there are 2 or more replicas in the cluster, `AllNodes` commands aren't actually sent to all nodes. 2. `SlotAddr::Replica` carries 2 separate semantic meanings - it could mean that the command is a readonly command, or that the user asked to route the command to a replica. The first case should be affected by the `read_from_replica` client flag, but the second case shouldn't - if the user requested that this specific command be routed to the replica, the specific request should override the prior configuration. * Fix multi-slot routes/addresses mismatch. If the `SlotMap` is partial, and some slots don't have addresses, then we need to communicate this back when getting addresses for multi-slot commands. Otherwise we the key indices won't match the addresses, and commands with the wrong keys will be sent to the wrong nodes. * fix typo * fix redis-rs#1045: impl `Clone`/`Copy` for `SetOptions` (redis-rs#1046) * docs: add "connection-manager" cfg attr (redis-rs#1048) * Fix new clippy lints. (redis-rs#1052) Replace Vec reference with a slice, and remove iterator trait when using ExactSizeIterator, since it encompasses it. * Rename Value enum types in order to match Redis RESP names. (redis-rs#779) * Rename Value::Bulk to Value::Array. * Rename Value::Status to Value::SimpleString. * Rename Value::Data to Value::BulkString. * Fix debug names of values. * Fix nightly lints. --------- Co-authored-by: Altan Özlü <5479094+altanozlu@users.noreply.github.com> Co-authored-by: Huxley Hu <framlog@users.noreply.github.com> Co-authored-by: Ahmad <39441506+ahmadbky@users.noreply.github.com> Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com>
* Initial implementation of RESP3 (#757) These changes implement all RESP3 types (excluding streamed types). RESP3 can be enabled per connection by adding `?resp3=true` to connection uri. It currently supports PubSub as RESP2 PubSub support in library, but in future PRs it'll support handling normal commands and PubSub messages in one connection. Only `num-bigint` is added as dependency to support `BigNumber` type. Changes made in support of #329 and #749 * Add RESP3 support to cluster connections. (#1001) * Resp3 Push Management (#898) * squash! * oops! * test invalidation in cluster && introduce client tracking options * introduce basic PubSub functionality to MultiplexedConnection and make tokio sender unbounded channel * fix tests & linter, make PushSender::Tokio as aio feature only * add resp3 to ci branches and fix cluster client tracking option * test dropping and update ci yml * remove unsubscribe fn and introduce unsubscribing by dropping receiver. * fix tests because RedisJson returns responses in an array when it's resp3 * override redisjson cache (it's a temp solution) * add -skip test_module to RESP3 testing and upgrade redis 6.2.4 to 6.2.13 * test json modules with RESP3 and get json fix from main * in redis v7 RedisJson is different with Resp3 🤔 * Implement Pub/Sub in Async Cluster & fmt & remove usage of is_err_and(stable only after v1.70) * don't use sharded pub/sub with redis v6 * use REDIS_VERSION in env instead of using HELLO command to fetch redis version * oops * fix linter * fix fmt and remove benchmark from CI * simplify PushManager and add tokio as non-optional dependency. * get fixes from 220c6a9 * use --test-threads=1 * override redisjson cache (it's a temp solution) * remove get_push_manager from traits & remove push manager from aio::Connection * remove client_tracking_options * remove 0.21.x from rust.yml * add tests for pushmanager * format & move push_info into a variable * change tests according to comments. * apply 6.2.4 changes && fmt * try to fix * remove con_addr & remove pub/sub support in cluster connections * add disconnection handling to sync, mpx, cm && test it * remove push_manager argument from connection creation * better docs * add has_reply function to PushKind * remove no response command support in mpx since it's not used in mpx pub/sub * apply changes from #994 * fix tests * Use enum instead of boolean for RESP version. (#1012) Since there's a discussion starting about what might become RESP4, this PR will make it easier to add more RESP versions in the future. * Rename Value enum types in order to match Redis RESP names. (#779) * Rename Value::Bulk to Value::Array. * Rename Value::Status to Value::SimpleString. * Rename Value::Data to Value::BulkString. * Fix debug names of values. * fix nightly comments. * reintroduce client tracking to tests. * fix merge errors. --------- Co-authored-by: Altan Özlü <5479094+altanozlu@users.noreply.github.com>
* Add lock file to keep MSRV constant. (redis-rs#1039) * [opt] preallocate buffer for evalsha in `Script` (redis-rs#1044) * Cluster: fix read from replica & missing slots. (redis-rs#965) * Cluster SlotMap: Allow missing slots. The cluster can still operate when some slots don't have coverage, so there's no reason that the connection won't work. Requests that should be routed to missing slots will be forwarded to a random node. * Fix SlotAddrs not holding all replicas. This change fixes 2 issues - 1. Since SlotAddrs saves at most 1 replica (or none, if `read_from_replica` is false), it means that when there are 2 or more replicas in the cluster, `AllNodes` commands aren't actually sent to all nodes. 2. `SlotAddr::Replica` carries 2 separate semantic meanings - it could mean that the command is a readonly command, or that the user asked to route the command to a replica. The first case should be affected by the `read_from_replica` client flag, but the second case shouldn't - if the user requested that this specific command be routed to the replica, the specific request should override the prior configuration. * Fix multi-slot routes/addresses mismatch. If the `SlotMap` is partial, and some slots don't have addresses, then we need to communicate this back when getting addresses for multi-slot commands. Otherwise we the key indices won't match the addresses, and commands with the wrong keys will be sent to the wrong nodes. * fix typo * fix redis-rs#1045: impl `Clone`/`Copy` for `SetOptions` (redis-rs#1046) * docs: add "connection-manager" cfg attr (redis-rs#1048) * Fix new clippy lints. (redis-rs#1052) Replace Vec reference with a slice, and remove iterator trait when using ExactSizeIterator, since it encompasses it. * Async cluster connection: Improve handling of missing connections (redis-rs#968) * aio::ClusterConnection: Report missing connections. This change should ensure that if a connection wasn't found, after redirecting to node, or when no random connection is available, then the cluster connection will refresh slots. * Add sleep to refresh slots action. * Cancel redirects after disconnects. If a redirected request reaches a disconnected node, the redirection will be cancelled, and the routing will revert to the original routing. * Move OperationTarget to Err side of result, and reduce generics. OperationTarget is used only on errors, so it should be in the `Err` case only. The added generics were used to hide a single type. * Handle disconnect from all nodes. If the async cluster connection completely disconnects from all nodes in the server, it will try again to connect to the inital nodes that were provided upon creation. This prevents a situation where the client removes connections incrementally, until the connection map is completely empty, and there are no connections to refresh slots on. * Appease Clippy (redis-rs#1061) * Reconnect on parsing errors. Parsing errors mean that the connection received a response it doesn't know how to handle. This means that it cannot make sense of the next values sent over the connection, and the connection must be replaced. related: redis-rs#984 (comment) * Save reconnected connections during retries. This change ensures that reconnect attempts that happen during retries, or new connections that happen after MOVED/ASKING errors, will be saved instead of constantly reconnecting until slots are refreshed. * [fix] make `Pipeline` handle returned bulks correctly * Update mio dependency due to vulnerability. (redis-rs#1064) GHSA-r8w9-5wcg-vfj7 * Simplify Sink polling logic. This removes unnecessary `match`es and `map` from the code, and moves the usage of `poll_recover` into `poll_flush`, so as not to block new requests while trying to recover a connection. * Remove the usage of aio::Connection in tests. `aio::Connection` is deprecated, we should test `aio::MultiplexedConnection` instead. * Fail CI if lock file isn't updated. * Handle server errors in array response. Currently server errors stop the parser and return a RedisError. This caused errors that are returned inside an array, such as transaction errors, to cause the rest of the array to not be parsed. This is solved by adding an internal value type that includes the server errors, so when parsing to the internal value type, the array will finish parsing, and then extracting the error. * Create a server error type. * Separate parsing errors from general response errors. Parsing errors are client-side errors, that are caused by bad output from the server. Response errors are server-side errors, caused by bad input from the user / client. Parse errors cause the client to be in an unrecoverable state. response errors are OK. * Release redis 0.25.0 / redis-test 0.4.0 * Update test version (redis-rs#1071) * Fix ambiguity in examples * Upgrade to socket2 0.5 * Avoid library dependency on futures-time * Merge the `resp3` branch. (redis-rs#1058) * Initial implementation of RESP3 (redis-rs#757) These changes implement all RESP3 types (excluding streamed types). RESP3 can be enabled per connection by adding `?resp3=true` to connection uri. It currently supports PubSub as RESP2 PubSub support in library, but in future PRs it'll support handling normal commands and PubSub messages in one connection. Only `num-bigint` is added as dependency to support `BigNumber` type. Changes made in support of redis-rs#329 and redis-rs#749 * Add RESP3 support to cluster connections. (redis-rs#1001) * Resp3 Push Management (redis-rs#898) * squash! * oops! * test invalidation in cluster && introduce client tracking options * introduce basic PubSub functionality to MultiplexedConnection and make tokio sender unbounded channel * fix tests & linter, make PushSender::Tokio as aio feature only * add resp3 to ci branches and fix cluster client tracking option * test dropping and update ci yml * remove unsubscribe fn and introduce unsubscribing by dropping receiver. * fix tests because RedisJson returns responses in an array when it's resp3 * override redisjson cache (it's a temp solution) * add -skip test_module to RESP3 testing and upgrade redis 6.2.4 to 6.2.13 * test json modules with RESP3 and get json fix from main * in redis v7 RedisJson is different with Resp3 🤔 * Implement Pub/Sub in Async Cluster & fmt & remove usage of is_err_and(stable only after v1.70) * don't use sharded pub/sub with redis v6 * use REDIS_VERSION in env instead of using HELLO command to fetch redis version * oops * fix linter * fix fmt and remove benchmark from CI * simplify PushManager and add tokio as non-optional dependency. * get fixes from 220c6a9 * use --test-threads=1 * override redisjson cache (it's a temp solution) * remove get_push_manager from traits & remove push manager from aio::Connection * remove client_tracking_options * remove 0.21.x from rust.yml * add tests for pushmanager * format & move push_info into a variable * change tests according to comments. * apply 6.2.4 changes && fmt * try to fix * remove con_addr & remove pub/sub support in cluster connections * add disconnection handling to sync, mpx, cm && test it * remove push_manager argument from connection creation * better docs * add has_reply function to PushKind * remove no response command support in mpx since it's not used in mpx pub/sub * apply changes from redis-rs#994 * fix tests * Use enum instead of boolean for RESP version. (redis-rs#1012) Since there's a discussion starting about what might become RESP4, this PR will make it easier to add more RESP versions in the future. * Rename Value enum types in order to match Redis RESP names. (redis-rs#779) * Rename Value::Bulk to Value::Array. * Rename Value::Status to Value::SimpleString. * Rename Value::Data to Value::BulkString. * Fix debug names of values. * fix nightly comments. * reintroduce client tracking to tests. * fix merge errors. --------- Co-authored-by: Altan Özlü <5479094+altanozlu@users.noreply.github.com> * fix flakey test * Fix linter. * fix cargo lock. --------- Co-authored-by: Huxley Hu <framlog@users.noreply.github.com> Co-authored-by: Ahmad <39441506+ahmadbky@users.noreply.github.com> Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com> Co-authored-by: James Lucas <jaymell@users.noreply.github.com> Co-authored-by: framlog <framlog@gmail.com> Co-authored-by: Neo Sun <huachuang20@gmail.com> Co-authored-by: Dirkjan Ochtman <dirkjan@ochtman.nl> Co-authored-by: Altan Özlü <5479094+altanozlu@users.noreply.github.com>
Hi!
This PR is initial implementation of RESP3, there will be more PR to support RESP3 better.
I've implemented all RESP3 types (excluding streamed types), RESP3 can be enabled per connection via
?resp3=true
addition to connection uri.It currently supports PubSub as RESP2 PubSub support in library but in future PRs it'll support handling normal commands and PubSub messages in one connection. #533
Only
num-bigint
is added as dependency to supportBigNumber
type.Changes in support of #329 and #749