RedisCluster (src/cluster.rs)

sea-streamer · sea-streamer-redis/src/cluster.rs · rust · Apache-2.0
database

Manages connections to a Redis cluster with key routing and reconnection logic.

// Source: https://github.com/SeaQL/sea-streamer | License: Apache-2.0 | Copyright 2023 Seafire Software Limited
// Provided via justclaw.it.com; keep this notice with the code.
use std::{collections::HashMap, fmt::Debug, sync::Arc};

use crate::{Connection, RedisConnectOptions, RedisResult};
use sea_streamer_types::{StreamErr, StreamUrlErr, StreamerUri, export::url::Url};

/// ID of a node in a Redis Cluster.
pub type NodeId = Url;

#[derive(Debug)]
/// A set of connections maintained to a Redis Cluster with key cache.
pub struct RedisCluster {
    pub(crate) cluster: StreamerUri,
    pub(crate) options: Arc<RedisConnectOptions>,
    pub(crate) conn: HashMap<NodeId, Connection>,
    pub(crate) keys: HashMap<String, NodeId>,
}

impl RedisCluster {
    /// Nothing happens until you call con

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key