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

Rust: Support clustered redis #392

Merged
merged 2 commits into from
Apr 25, 2022
Merged

Conversation

jaymell
Copy link
Contributor

@jaymell jaymell commented Apr 21, 2022

No description provided.

@tasn
Copy link
Member

tasn commented Apr 21, 2022

  1. Branch conflicts.
  2. There's no need to close a PR and open another, you can just push to the original.

Copy link
Member

@tasn tasn left a comment

Choose a reason for hiding this comment

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

Haven't reviewed. I'll let @svix-daniel and @svix-dylan take the first jab, but from skimming over it I think it looks good!

There are a lost of unrelated changes though both for spacing and code which make reviewing hard. Can you please fix this?

server/svix-server/src/cfg.rs Outdated Show resolved Hide resolved
server/svix-server/src/core/cache.rs Outdated Show resolved Hide resolved
@jaymell jaymell force-pushed the clustered-redis3 branch 2 times, most recently from 5c2f2d2 to 0256c3b Compare April 22, 2022 05:07
Copy link
Contributor

@svix-dylan svix-dylan left a comment

Choose a reason for hiding this comment

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

I see some notes for things still being cleaned up but this looks good! Between this and #393 we'll have some conflicts at first, but they should be pretty easy to sort out.

server/svix-server/src/core/message_app.rs Outdated Show resolved Hide resolved
@jaymell jaymell force-pushed the clustered-redis3 branch 4 times, most recently from 744c70c to f92d855 Compare April 23, 2022 04:36
@jaymell jaymell marked this pull request as ready for review April 25, 2022 14:42
Copy link
Contributor

@svix-dylan svix-dylan left a comment

Choose a reason for hiding this comment

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

Noting it looks like you still intend to put redis_cache type determination in a helper method? Re: FIXMEs in lib.rs, idempotency.rs, cache.rs.

server/svix-server/src/core/message_app.rs Outdated Show resolved Hide resolved
Add support for clustered redis connections with `RedisCluster`
cache/queue types. Also addd a basic script to run all tests
against various queue and cache backend types.
@svix-james svix-james merged commit 8e08fe8 into svix:main Apr 25, 2022
server/svix-server/src/core/cache/redis.rs Show resolved Hide resolved
server/svix-server/src/core/cache/redis.rs Show resolved Hide resolved
Comment on lines +37 to 42
let redis_dsn = || {
cfg.redis_dsn
.as_ref()
.expect("Redis DSN not found")
.as_str()
};
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit weird, why have it as a function if it's just borrow in both places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Putting the expect in one place instead of in 4 different spots was the goal.

Copy link
Member

Choose a reason for hiding this comment

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

Why not have:

Suggested change
let redis_dsn = || {
cfg.redis_dsn
.as_ref()
.expect("Redis DSN not found")
.as_str()
};
let redis_dsn =
cfg.redis_dsn
.as_ref()
.expect("Redis DSN not found")
.as_str()
;

This puts it just one in one place, no?

Copy link
Contributor Author

@jaymell jaymell Apr 28, 2022

Choose a reason for hiding this comment

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

This will panic if redis_dsn is not defined.

server/svix-server/src/queue/redis.rs Show resolved Hide resolved
@@ -144,11 +165,14 @@ impl TaskQueueSend for RedisQueueProducer {
let key = to_redis_key(&delivery);
if let Some(timestamp) = timestamp {
let _: () = pool
.zadd(DELAYED, key, timestamp.timestamp())
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the worst experience here everywhere by using redis::Cmd::zadd instead of pool.zadd, I wonder if we should have just had our own wrappers for these functions instead of making the experience worst everywhere.

Can probably easily just implement it with a macro.

Copy link
Member

Choose a reason for hiding this comment

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

What I actually meant is that we can have the behavior shared. So I much rather you to have a shared trait with default implementation that defines a zadd function that internally calls query_async(redis::Cmd::Zadd) so that using the API is less terrible. Does this make sense?

server/run-tests.sh Show resolved Hide resolved
server/svix-server/src/queue/redis.rs Show resolved Hide resolved
};

tracing::debug!("Cache type: {:?}", cfg.cache_type);
let cache = match cfg.cache_type {
CacheType::Redis => {
let mgr = crate::redis::create_redis_pool(redis_dsn(), false).await;
Copy link
Member

Choose a reason for hiding this comment

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

I said it elsewhere but can't see the comment now. Please don't use true/false like this, but rather have a differently named function (internally it can call a private true/false function).

svix-james added a commit that referenced this pull request Apr 28, 2022
Addresses additional comments from #392.
@tasn tasn linked an issue Apr 28, 2022 that may be closed by this pull request
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.

Support Clustered Redis in Server
4 participants