Channel inspect api

This commit is contained in:
Dominik Werder
2025-03-26 14:28:38 +01:00
parent f1286d9ba6
commit a91f6d7070
4 changed files with 95 additions and 30 deletions
+7
View File
@@ -912,6 +912,13 @@ impl ConnCommand {
}
}
pub fn channel_inspect(name: String, tx: Sender<serde_json::Value>) -> Self {
Self {
id: Self::make_id(),
kind: ConnCommandKind::ChannelInspectFull(CmdChannelInspectFull { name, tx }),
}
}
pub fn shutdown() -> Self {
Self {
id: Self::make_id(),
+23 -16
View File
@@ -226,15 +226,10 @@ impl fmt::Debug for ChannelStatusesRequest {
}
}
#[derive(Debug)]
pub enum ChannelCommandKind {
InspectDetail,
}
#[derive(Debug)]
pub struct ChannelCommand {
pub channel: String,
pub kind: ChannelCommandKind,
pub conn_command: ConnCommand,
}
#[derive(Debug)]
@@ -245,6 +240,7 @@ pub enum ConnSetCmd {
ChannelRemove(ChannelRemove),
Shutdown,
ChannelStatuses(ChannelStatusesRequest),
// TODO rename to ConnCommand because it must be handled by some specific Conn
ChannelCommand(ChannelCommand),
}
@@ -1080,16 +1076,27 @@ impl CaConnSet {
return Ok(());
}
// TODO handle, send to corresponding CaConn
// let channels_ca_conn_set = self
// .channel_states
// .iter()
// .filter(|(k, _)| k.name() == cmd.channel)
// .map(|(k, v)| (k.name().to_string(), v.clone()))
// .collect();
// let item = ChannelStatusesResponse { channels_ca_conn_set };
// if req.tx.try_send(item).is_err() {
// self.stats.response_tx_fail.inc();
// }
let name = cmd.channel.clone();
let mut cmd = Some(cmd);
// TODO no need to iterate anymore
self.channel_states
.iter_mut()
.filter(|(k, _)| k.name() == name)
.map(|(_, st1)| {
if let ChannelStateValue::Active(st2) = &mut st1.value {
if let ActiveChannelState::WithStatusSeriesId(st3) = st2 {
if let WithStatusSeriesIdStateInner::WithAddress { addr, state: _ } = &mut st3.inner {
let addr2 = SocketAddr::V4(*addr);
self.ca_conn_ress.get_mut(&addr2).map(|q| {
if let Some(cmd) = cmd.take() {
q.cmd_queue.push_back(cmd.conn_command);
}
});
}
}
};
})
.for_each(|_| ());
Ok(())
}