Skip to content

Commit

Permalink
Merge pull request #23 from nihohit/fix-replica-generation
Browse files Browse the repository at this point in the history
create_topology_from_config: Use all replicas.
  • Loading branch information
nihohit authored Aug 16, 2023
2 parents 0bc5edf + 69b3d52 commit 2e642ec
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions redis/tests/support/mock_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,21 @@ pub fn create_topology_from_config(name: &str, slots_config: Vec<MockSlotRange>)
let slots_vec = slots_config
.into_iter()
.map(|slot_config| {
let replicas = slot_config
.replica_ports
.into_iter()
.flat_map(|replica_port| {
vec![
Value::Data(name.as_bytes().to_vec()),
Value::Int(replica_port as i64),
]
})
.collect();
Value::Bulk(vec![
let mut config = vec![
Value::Int(slot_config.slot_range.start as i64),
Value::Int(slot_config.slot_range.end as i64),
Value::Bulk(vec![
Value::Data(name.as_bytes().to_vec()),
Value::Int(slot_config.primary_port as i64),
]),
Value::Bulk(replicas),
])
];
config.extend(slot_config.replica_ports.into_iter().map(|replica_port| {
Value::Bulk(vec![
Value::Data(name.as_bytes().to_vec()),
Value::Int(replica_port as i64),
])
}));
Value::Bulk(config)
})
.collect();
Value::Bulk(slots_vec)
Expand Down

0 comments on commit 2e642ec

Please sign in to comment.