Skip to content
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

Add read from replica round robin to client CMD #315

Merged
merged 6 commits into from
Aug 3, 2023

Conversation

shachlanAmazon
Copy link
Contributor

babushka-core/src/client/client_cmd.rs Outdated Show resolved Hide resolved
babushka-core/src/client/client_cmd.rs Outdated Show resolved Hide resolved
babushka-core/src/client/client_cmd.rs Outdated Show resolved Hide resolved
babushka-core/src/client/client_cmd.rs Show resolved Hide resolved
(0..4).map(|_| get_listener_on_available_port()).collect();
let mut primary_responses = std::collections::HashMap::new();
primary_responses.insert(
"*2\r\n$4\r\nINFO\r\n$11\r\nREPLICATION\r\n".to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a parser function to encode the commands into resp protocol, instead of hardcoding it?

Copy link
Contributor Author

@shachlanAmazon shachlanAmazon Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what format would you prefer?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the same format (resp), but why dont you use some parser.to_resp(["INFO", "REPLICATION"])?
Dont we have this functionallity in redis-rs parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, only with Value, which is even more verbose. But if you prefer, I can use Value.

Copy link
Collaborator

@barshaul barshaul Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better (dont they have some easy fuction for vec=>Value and then Value=>resp?? eef).
I think it would make it harder to write tests if each test writer will need to manually encode the expected result to a resp string

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't resolve to Value, and doesn't seem significantly less verbose.


for mock in mocks.iter() {
for _ in 0..3 {
mock.add_response(&cmd, "$3\r\nbar\r\n".to_string());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same - can we pass simple response string and let it be parsed to resp inside add_resopnse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will we handle complex responses such as arrays?

babushka-core/tests/test_client_cmd.rs Show resolved Hide resolved
babushka-core/src/client/client_cmd.rs Outdated Show resolved Hide resolved
@shachlanAmazon shachlanAmazon force-pushed the read-from-replica-cmd branch 3 times, most recently from b479ffb to feaa8c6 Compare July 31, 2023 09:49
@shachlanAmazon
Copy link
Contributor Author

@barshaul round

Copy link
Collaborator

@barshaul barshaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, some comments

babushka-core/src/client/client_cmd.rs Outdated Show resolved Hide resolved
babushka-core/src/client/client_cmd.rs Outdated Show resolved Hide resolved
pub(super) fn reconnect(&self) {
{
pub(super) fn reconnect(&self, force_reconnect: bool) {
if !force_reconnect {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to force reconnect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if the client was created in reconnecting state, without force reconnection it will never start the initial reconnect attempt.

@shachlanAmazon shachlanAmazon force-pushed the read-from-replica-cmd branch 2 times, most recently from 5635b36 to 944b2d6 Compare August 2, 2023 13:23
This is done by adding an initial state for `ReconnectingConnection`,
which doesn't block reconnect.
Additionally, as per request, moved the call to `reconnect` when
creating a disconnected connection into `ReconnectingConnection`.
This is done in order to handle heartbeats.
@shachlanAmazon shachlanAmazon force-pushed the read-from-replica-cmd branch 2 times, most recently from 830cfed to 321d7b4 Compare August 2, 2023 16:51
@shachlanAmazon
Copy link
Contributor Author

@barshaul pushed some more commits with various fixes needed in order to reduce flakeyness. please review.

@shachlanAmazon shachlanAmazon merged commit 27c2fb2 into valkey-io:main Aug 3, 2023
7 of 8 checks passed
@shachlanAmazon shachlanAmazon deleted the read-from-replica-cmd branch August 3, 2023 12:59
Yury-Fridlyand added a commit that referenced this pull request Jun 3, 2024
Java: Update implementation for `FUNCTION LOAD`. (#315)

* Update implementation for `FUNCTION LOAD`.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Co-authored-by: Aaron <69273634+aaron-congo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants