mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 05:11:09 +00:00
Add a sub_libp2p_notifications_queues_size Prometheus metric (#5503)
* Add a sub_libp2p_notifications_queues_size Prometheus metric * Fix network tests * Address review
This commit is contained in:
@@ -38,7 +38,7 @@ use futures::{prelude::*, ready};
|
||||
use futures_codec::Framed;
|
||||
use libp2p::core::{UpgradeInfo, InboundUpgrade, OutboundUpgrade, upgrade};
|
||||
use log::error;
|
||||
use std::{borrow::Cow, collections::VecDeque, io, iter, mem, pin::Pin, task::{Context, Poll}};
|
||||
use std::{borrow::Cow, collections::VecDeque, convert::TryFrom as _, io, iter, mem, pin::Pin, task::{Context, Poll}};
|
||||
use unsigned_varint::codec::UviBytes;
|
||||
|
||||
/// Maximum allowed size of the two handshake messages, in bytes.
|
||||
@@ -280,6 +280,13 @@ where TSubstream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
||||
}
|
||||
}
|
||||
|
||||
impl<TSubstream> NotificationsOutSubstream<TSubstream> {
|
||||
/// Returns the number of items in the queue, capped to `u32::max_value()`.
|
||||
pub fn queue_len(&self) -> u32 {
|
||||
u32::try_from(self.messages_queue.len()).unwrap_or(u32::max_value())
|
||||
}
|
||||
}
|
||||
|
||||
impl<TSubstream> Sink<Vec<u8>> for NotificationsOutSubstream<TSubstream>
|
||||
where TSubstream: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user