Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Add commands #49

Merged
merged 6 commits into from
May 26, 2021
Merged

Add commands #49

merged 6 commits into from
May 26, 2021

Conversation

tbmreza
Copy link
Contributor

@tbmreza tbmreza commented May 22, 2021

@barkanido
Copy link

@tbmreza maybe take a look on #50 ? for implementing TYPE command? it might help you when/if it is merged.

@tbmreza
Copy link
Contributor Author

tbmreza commented May 22, 2021

maybe take a look on #50 ? for implementing TYPE command? it might help you when/if it is merged.

@barkanido Thanks for the heads-up. Instead of matching on self.data_mapper.get(key), after that PR is merged I could match on self.meta(key).

This (#49) shouldn't be in that PR's way though, unless I'm missing something.

@tbmreza
Copy link
Contributor Author

tbmreza commented May 22, 2021

This one case fails, haven't dug into it.
server::tests::expire_and_ttl (https://github.com/Qovery/RedisLess/blob/main/redisless/src/server/tests/mod.rs#L102)
@barkanido Any idea?

Other than that, I did rebuild and retest using the python client. Please let me know what you think. @clarity0 @evoxmusic

Comment on lines 109 to 115
match self.data_mapper.get(key) {
Some(RedisMeta {data_type: RedisType::String, ..}) => "string".as_bytes(),
Some(RedisMeta {data_type: RedisType::List, ..}) => "list".as_bytes(),
Some(RedisMeta {data_type: RedisType::Set, ..}) => "set".as_bytes(),
Some(RedisMeta {data_type: RedisType::Hash, ..}) => "hash".as_bytes(),
None => "none".as_bytes(),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

use let value_type = match ... here and then return value_type.as_bytes()

@@ -18,6 +18,7 @@ pub trait Storage {
fn read(&mut self, key: &[u8]) -> Option<&[u8]>;
fn remove(&mut self, key: &[u8]) -> u32;
fn contains(&mut self, key: &[u8]) -> bool;
fn value_type(&mut self, key: &[u8]) -> &[u8];
Copy link
Contributor

Choose a reason for hiding this comment

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

I personally prefer the name type_of for this method but that's whatever

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah my first thought was type_of(key) that doesn't return the type of the key, but the type of the value inside it is confusing.

@clarity0
Copy link
Contributor

Can you add tests to src/server/tests/mod.rs ? DECR and DECRBY are supported by redis-rs

@barkanido
Copy link

This one case fails, haven't dug into it.
server::tests::expire_and_ttl (https://github.com/Qovery/RedisLess/blob/main/redisless/src/server/tests/mod.rs#L102)
@barkanido Any idea?

Other than that, I did rebuild and retest using the python client. Please let me know what you think. @clarity0 @evoxmusic

works on my machine in main, but the root cause should be that the test sleeps and then asserting on the remaining TTL. this approach although easy to implement produces somewhat unstable tests (sleep is non-deterministic). I suggest you fiddle with the duration var a bit to stabilize this.

@tbmreza
Copy link
Contributor Author

tbmreza commented May 23, 2021

works on my machine in main, but the root cause should be that the test sleeps and then asserting on the remaining TTL. this approach although easy to implement produces somewhat unstable tests (sleep is non-deterministic). I suggest you fiddle with the duration var a bit to stabilize this.

On my machine the returned ttl is very unstable. I ended up changing the delta to 10x. The test passes now, hopefully it doesn't defeat its purpose :D @barkanido

@tbmreza
Copy link
Contributor Author

tbmreza commented May 23, 2021

Anything else? @clarity0

@evoxmusic
Copy link
Contributor

@tbmreza is it all good for you? (I'll review if yes - please use "draft" mode if you are still working on it). Thank you guys

@tbmreza
Copy link
Contributor Author

tbmreza commented May 23, 2021

@evoxmusic yes, all good to me.

@evoxmusic
Copy link
Contributor

It looks like tests are failing @tbmreza - can you check?

@tbmreza
Copy link
Contributor Author

tbmreza commented May 23, 2021

That's weird. A different test case (server::tests::mget) is flaky on my machine, not the one that's failing in that CI.

What do you suggest me to do? I'm thinking about wrapping the Connection's get result in an if-let so it won't panic. But that's practically ignoring the test case. @evoxmusic

@barkanido
Copy link

That's weird. A different test case (server::tests::mget) is flaky on my machine, not the one that's failing in that CI.

What do you suggest me to do? I'm thinking about wrapping the Connection's get result in an if-let so it won't panic. But that's practically ignoring the test case. @evoxmusic

Yeah, tests are designed to panic on failure in rust. Why is it flaky though? Maybe it discovered a bug?

@tbmreza
Copy link
Contributor Author

tbmreza commented May 24, 2021

That's weird. A different test case (server::tests::mget) is flaky on my machine, not the one that's failing in that CI.

What do you suggest me to do? I'm thinking about wrapping the Connection's get result in an if-let so it won't panic. But that's practically ignoring the test case. @evoxmusic

Yeah, tests are designed to panic on failure in rust. Why is it flaky though? Maybe it discovered a bug?

By flaky I mean I simply rerun the test (without any change) and the test passes.

@tbmreza
Copy link
Contributor Author

tbmreza commented May 24, 2021

Oops didn't read your comment correctly. I'll try to look why when I can.

Comment on lines 39 to 47
let _ = con
.send_packed_command(
cmd("INCRBY")
.arg("0")
.arg("500")
.get_packed_command()
.as_slice(),
)
.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of sending a custom command, u can call con.incr(...) since the redis-rs client does implement the INCRBY command. You can do the same for any other command that is implemented directly by redis-rs, DECRBY is also there. 😄

@tbmreza tbmreza closed this May 24, 2021
@tbmreza tbmreza reopened this May 24, 2021
@tbmreza
Copy link
Contributor Author

tbmreza commented May 25, 2021

So I made a mistake by reusing the same port number for different cases. That sometimes causes starting the server returns Timeout.

@evoxmusic evoxmusic merged commit 64f3cd7 into Qovery:main May 26, 2021
@tbmreza tbmreza deleted the add-commands branch May 27, 2021 02:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants