Multi proxy.shard always set to first
rongfengliang opened this issue · comments
rong fengliang commented
Can't get multi proxy.shard config correct because hard code for set proxy
fn map_shards() -> [Option<Uri>; MAX_SHARDS as usize] {
// Notice: this array cannot be initialized using the short format, as hyper::Uri doesnt \
// implement the Copy trait, hence the ugly hardcoded initialization vector w/ Nones.
let mut shards = [
None, None, None, None, None, None, None, None, None, None, None, None, None, None, None,
None,
];
for shard in &APP_CONF.proxy.shard {
// Shard number overflows?
if shard.shard >= MAX_SHARDS {
panic!("shard number overflows maximum of {} shards", MAX_SHARDS);
}
// Store this shard
shards[shard.shard as usize] = Some(
format!(
"http://{}:{}",
// always set to first
APP_CONF.proxy.shard[0].host, APP_CONF.proxy.shard[0].port
)
.parse()
.expect("could not build shard uri"),
);
}
shards
}
should be
fn map_shards() -> [Option<Uri>; MAX_SHARDS as usize] {
// Notice: this array cannot be initialized using the short format, as hyper::Uri doesnt \
// implement the Copy trait, hence the ugly hardcoded initialization vector w/ Nones.
let mut shards = [
None, None, None, None, None, None, None, None, None, None, None, None, None, None, None,
None,
];
for shard in &APP_CONF.proxy.shard {
// Shard number overflows?
if shard.shard >= MAX_SHARDS {
panic!("shard number overflows maximum of {} shards", MAX_SHARDS);
}
// Store this shard
shards[shard.shard as usize] = Some(
format!(
"http://{}:{}",
shard.host, shard.port
)
.parse()
.expect("could not build shard uri"),
);
}
shards
}
Valerian Saliou commented
Thanks for the report, it looks like a dumb mistake from my end. I'm fixing this right now.
Valerian Saliou commented
This should be fixed now, can you try building master and let me know if your multi-shard setup works now?
rong fengliang commented
@valeriansaliou thanks,it works