mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
http and ws: fix build errors with --no-default-features
This commit is contained in:
parent
acabf1581f
commit
964636db7c
4 changed files with 16 additions and 7 deletions
|
|
@ -99,6 +99,7 @@ impl TorrentMaps {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
pub fn update_torrent_metrics(&self) {
|
pub fn update_torrent_metrics(&self) {
|
||||||
self.ipv4.torrent_gauge.set(self.ipv4.torrents.len() as f64);
|
self.ipv4.torrent_gauge.set(self.ipv4.torrents.len() as f64);
|
||||||
self.ipv6.torrent_gauge.set(self.ipv6.torrents.len() as f64);
|
self.ipv6.torrent_gauge.set(self.ipv6.torrents.len() as f64);
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ use crate::workers::socket::calculate_in_message_consumer_index;
|
||||||
use crate::workers::socket::{ip_version_to_metrics_str, WORKER_INDEX};
|
use crate::workers::socket::{ip_version_to_metrics_str, WORKER_INDEX};
|
||||||
|
|
||||||
/// Optional second tuple field is for peer id hex representation
|
/// Optional second tuple field is for peer id hex representation
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
type PeerClientGauge = (Gauge, Option<Gauge>);
|
type PeerClientGauge = (Gauge, Option<Gauge>);
|
||||||
|
|
||||||
pub struct ConnectionRunner {
|
pub struct ConnectionRunner {
|
||||||
|
|
@ -68,6 +69,7 @@ impl ConnectionRunner {
|
||||||
let clean_up_data = ConnectionCleanupData {
|
let clean_up_data = ConnectionCleanupData {
|
||||||
announced_info_hashes: Default::default(),
|
announced_info_hashes: Default::default(),
|
||||||
ip_version: self.ip_version,
|
ip_version: self.ip_version,
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
opt_peer_client: Default::default(),
|
opt_peer_client: Default::default(),
|
||||||
#[cfg(feature = "metrics")]
|
#[cfg(feature = "metrics")]
|
||||||
active_connections_gauge: ::metrics::gauge!(
|
active_connections_gauge: ::metrics::gauge!(
|
||||||
|
|
@ -597,6 +599,7 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionWriter<S> {
|
||||||
struct ConnectionCleanupData {
|
struct ConnectionCleanupData {
|
||||||
announced_info_hashes: Rc<RefCell<HashMap<InfoHash, PeerId>>>,
|
announced_info_hashes: Rc<RefCell<HashMap<InfoHash, PeerId>>>,
|
||||||
ip_version: IpVersion,
|
ip_version: IpVersion,
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
opt_peer_client: Rc<RefCell<Option<PeerClientGauge>>>,
|
opt_peer_client: Rc<RefCell<Option<PeerClientGauge>>>,
|
||||||
#[cfg(feature = "metrics")]
|
#[cfg(feature = "metrics")]
|
||||||
active_connections_gauge: Gauge,
|
active_connections_gauge: Gauge,
|
||||||
|
|
|
||||||
|
|
@ -240,14 +240,14 @@ async fn clean_connections(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
::log::info!(
|
|
||||||
"cleaned connections in worker {}, {} references remaining",
|
|
||||||
WORKER_INDEX.get(),
|
|
||||||
connection_slab.borrow_mut().len()
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(feature = "metrics")]
|
#[cfg(feature = "metrics")]
|
||||||
{
|
{
|
||||||
|
::log::info!(
|
||||||
|
"cleaned connections in worker {}, {} references remaining",
|
||||||
|
WORKER_INDEX.get(),
|
||||||
|
connection_slab.borrow_mut().len()
|
||||||
|
);
|
||||||
|
|
||||||
// Increment gauges by zero to prevent them from being removed due to
|
// Increment gauges by zero to prevent them from being removed due to
|
||||||
// idleness
|
// idleness
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@ impl TorrentMap {
|
||||||
server_start_instant,
|
server_start_instant,
|
||||||
request_sender_meta,
|
request_sender_meta,
|
||||||
&request,
|
&request,
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
&self.peer_gauge,
|
&self.peer_gauge,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -260,7 +261,11 @@ impl TorrentMap {
|
||||||
|
|
||||||
pub fn handle_connection_closed(&mut self, info_hash: InfoHash, peer_id: PeerId) {
|
pub fn handle_connection_closed(&mut self, info_hash: InfoHash, peer_id: PeerId) {
|
||||||
if let Some(torrent_data) = self.torrents.get_mut(&info_hash) {
|
if let Some(torrent_data) = self.torrents.get_mut(&info_hash) {
|
||||||
torrent_data.handle_connection_closed(peer_id, &self.peer_gauge);
|
torrent_data.handle_connection_closed(
|
||||||
|
peer_id,
|
||||||
|
#[cfg(feature = "metrics")]
|
||||||
|
&self.peer_gauge,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue