diff --git a/src/rpc/sharding.rs b/src/rpc/sharding.rs index 3192adff649d23a09f08fc9c33857eef764e5615..e09e451f7d4949e949df7c599caf9a7f7cd59741 100644 --- a/src/rpc/sharding.rs +++ b/src/rpc/sharding.rs @@ -22,11 +22,12 @@ crate::define_rpc_request! { node.wait_index(req.applied, req.timeout)?; node.status().check_term(req.term)?; - let cfg = node.storage.properties.target_vshard_config()?; - crate::tlog!(Debug, "vshard config: {cfg:?}"); - let lua = ::tarantool::lua_state(); + let mut cfg = node.storage.properties.target_vshard_config()?; + cfg.listen = Some(lua.eval("return box.info.listen")?); + crate::tlog!(Debug, "vshard config: {cfg:?}"); + if !req.do_reconfigure { if let Some(tlua::True) = lua.eval("return pico._vshard_is_configured")? { return Ok(Response {}); diff --git a/src/vshard.rs b/src/vshard.rs index eb8d7801b08b95efaf4c88860c8d64ba642e95ec..68a952137b80faf97d4b638a929351130ffed0c4 100644 --- a/src/vshard.rs +++ b/src/vshard.rs @@ -14,6 +14,13 @@ use std::collections::HashMap; pub struct VshardConfig { sharding: HashMap<String, ReplicasetSpec>, discovery_mode: DiscoveryMode, + + /// This field is not stored in the global storage, instead + /// it is set right before the config is passed into vshard.*.cfg, + /// otherwise vshard will override it with an incorrect value. + #[serde(skip_serializing_if="Option::is_none")] + #[serde(default)] + pub listen: Option<String>, } #[rustfmt::skip] @@ -110,6 +117,7 @@ impl VshardConfig { } Self { + listen: None, sharding, discovery_mode: DiscoveryMode::On, }