-
Notifications
You must be signed in to change notification settings - Fork 43
Adds support for PubSub state restoration #375
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: develop
Are you sure you want to change the base?
Adds support for PubSub state restoration #375
Conversation
|
@mzimbres this is a prototype of the pubsub state restoration feature. I'd like to get this done before the next release, so we can make The idea is that, when adding a This requires inspecting command arguments from This is still missing docs and tests - let me know if you think this is the right approach before spending time on these. Also, I can split the PR into smaller ones (e.g. deprecating the old extension point first) if you think it's best. |
| sentinel_config sentinel{}; | ||
|
|
||
| // (TODO: document properly) Do we want to re-subscribe to channels on reconnection? | ||
| bool restore_pubsub_state = false; |
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 think there should be no option to deactivate restoration in the connection. We can offer a request option e.g. request::config::track_subscriptions.
|
|
||
| enum class pubsub_change_type; | ||
|
|
||
| class pubsub_state { |
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.
Perhpas name it subscriptions or subscription _tracker?
|
|
||
| void pubsub_state::commit_changes(const request& req) | ||
| { | ||
| for (const auto& ch : detail::request_access::pubsub_changes(req)) |
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.
| for (const auto& ch : detail::request_access::pubsub_changes(req)) | |
| for (const auto& ch : request_access::pubsub_changes(req)) |
|
This will be a great improvement over the current complex resubscribe loop, so you have my approval. I don't understand yet why |
At the point of |
I think we should avoid all this trouble by adding |
|
This does work for this task, but idk if it does for cluster (I don't have the answer to this question, maybe it does). Cluster needs to know the key each command is acting on and compute its hash to know where to direct the command to. We could support some syntax like Although you probably need a regular and a range version of the command. |
This looks interesting because with reflection we could perhaps generate these structs automatically from a description doc (I would call it |
|
ATM reflection can only generate aggregates. I lack the vision to know if that'd be enough (it wouldn't if we need a templated range, for instance). It'd much better for usability having functions in request, actually. But then request is gonna end up having zounds of functions, and not all of them used frequently. |
|
How about req.push2(subscribe, {"channel", "channel2"});Where subscribe is an object of type struct subscribe_t {
void operator ()(request& r, initializer_list<string_view>);
// maybe other overloads
};so push2 can just call into the passed object forwarding all the args. This way we can define each command (or family of commands) in a separate header. |
This is what I like most so far. I don't mind having lots of member function and overloads for each command. The complexity is not our invention but intrinsic to Redis. The only question is what to do when Valkey and Redis have a different definition for the same command. |
|
How about req.push2(subscribe).with({"ch1", "ch2"});The difference is that we avoid forwarding args in push2. This allows us to use things like initializer lists without incurring in problems. I'm wary of adding too many member functions to request. We can easily end up with 1000 member functions if we end up adding support for all commands, each one having different overloads. This may not be the best for compile times. |
Adds config::restore_pubsub_state and command_context
Deprecates the boost_redis_to_bulk extension point taking a std::string& argument, in favor of an extension point with the same name taking a command_context argument
close #367