dahomey-technologies / rustis

An asynchronous Redis client for Rust

Home Page:https://docs.rs/rustis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shall we use slice type for `instances` field for `SentinelConfig`?

bioinformatist opened this issue · comments

Currently the field is of type Vec<(String, u16)>. However, use a slice (e.g., &[(String, u16)]) will result in better performance. In our specific scenario, the address remains fixed when used in production (using the service name in Docker Swarm cluster), so the instance addresses can be constant in the binary:

const INSTANCES: [(&str, u16); 3] = [
    ("redis-sentinel-1", 26379),
    ("redis-sentinel-2", 26379),
    ("redis-sentinel-3", 26379),
];

Even it could be &[(&str, u16)] by add a trait IntoSentinelConfig similar to IntoConfig. Is it feasible for me to implement this?

Hi @bioinformatist,

Would you be acceptable for you to use an Url to store your sentinel addresses as explained here ?

In your case the URL would look like:

redis+sentinel://redis-sentinel-1:26379,redis-sentinel-2:26379,redis-sentinel-3:26379/yourservicename

Where exactly do you want more performance?
Anyway, if we add a trait, we would have a copy between IntoSentinelConfig and SentinelConfig...

Oh sorry I forgot about the URL syntax. It's the de facto best solution for us! I just want the Sentinel's IP addresses to be hard coded.

Thanks!