Skip to content

Commit

Permalink
fix doc
Browse files Browse the repository at this point in the history
Signed-off-by: Shoham Elias <[email protected]>
  • Loading branch information
shohamazon committed Jan 28, 2025
1 parent 23b3fbe commit deee614
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
11 changes: 6 additions & 5 deletions glide-core/redis-rs/redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2248,16 +2248,17 @@ where
/// Suppose we have a pipeline with multiple commands that were split and executed on different nodes.
/// This function will aggregate the responses for commands that were split across multiple nodes.
///
/// ```rust,no_run
/// ```rust,compile_fail
/// // Example pipeline with commands that might be split across nodes
///
/// let mut pipeline_responses = vec![
/// vec![(Value::Int(1), "node1".to_string()), (Value::Int(2), "node2".to_string())], (Value::Int(3), "node3".to_string())] // represents `DBSIZE``
/// vec![(Value::Int(1), "node1".to_string()), (Value::Int(2), "node2".to_string()), (Value::Int(3), "node3".to_string())], // represents `DBSIZE`
/// vec![(Value::Int(3), "node3".to_string())],
/// vec![(Value::SimpleString("PONG"), "node1".to_string()), (Value::SimpleString("PONG"), "node2".to_string()), (Value::SimpleString("PONG"), "node3".to_string())], // represents `PING`
/// vec![(Value::SimpleString("PONG".to_string()), "node1".to_string()), (Value::SimpleString("PONG".to_string()), "node2".to_string()), (Value::SimpleString("PONG".to_string()), "node3".to_string())], // represents `PING`
/// ];
/// let response_policies = vec![
/// (0, MultipleNodeRoutingInfo::AllNodes, Some(ResponsePolicy::Aggregate(AggregateOp::Sum))),
/// (2, MultipleNodeRoutingInfo::AllNodes, Some(ResponsePolicy::AllSuceeded),
/// (2, MultipleNodeRoutingInfo::AllNodes, Some(ResponsePolicy::AllSucceeded)),
/// ];
///
/// // Aggregating the responses
Expand All @@ -2266,7 +2267,7 @@ where
/// // After aggregation, pipeline_responses will be updated with aggregated results
/// assert_eq!(pipeline_responses[0], vec![(Value::Int(6), "".to_string())]);
/// assert_eq!(pipeline_responses[1], vec![(Value::Int(3), "node3".to_string())]);
/// assert_eq!(pipeline_responses[2], vec![(Value::SimpleString("PONG"), "".to_string())]);
/// assert_eq!(pipeline_responses[2], vec![(Value::SimpleString("PONG".to_string()), "".to_string())]);
/// ```
///
/// This function is essential for handling multi-node commands in a Redis cluster, ensuring that responses from different nodes are correctly aggregated and processed.
Expand Down
14 changes: 2 additions & 12 deletions glide-core/redis-rs/redis/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,8 @@ impl Pipeline {
self
}

/// This enables sub-pipeline mode. In sub-pipeline mode, the whole pipeline is enclosed in
/// `MULTI`/`EXEC` and the return value is a nested array of results. This is useful when
/// you want to execute a pipeline inside another pipeline.
/// ```rust,no_run
/// # let client = redis::Client::open("redis://
/// 127.0.0.1/").unwrap();
/// # let mut con = client.get_connection(None).unwrap();
/// let (k1, k2) : (i32, i32) = redis::pipe()
/// .atomic()
/// .cmd("SET").arg("key_1").arg(42).ignore()
///
///
/// Enables sub-pipeline mode, indicating that this pipeline is part of a larger pipeline
/// split across multiple nodes.
pub fn sub_pipeline(&mut self) -> &mut Pipeline {
self.is_sub_pipeline = true;
self
Expand Down

0 comments on commit deee614

Please sign in to comment.