Skip to content

Commit

Permalink
address name collision
Browse files Browse the repository at this point in the history
  • Loading branch information
brayniac committed Jun 26, 2024
1 parent 3be0401 commit 24f58bf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ mod metrics;
pub use metrics::*;

#[cfg(feature = "metrics")]
macro_rules! metrics {
macro_rules! metric {

Check failure

Code scanning / clippy

cannot find macro metrics in this scope Error

cannot find macro metrics in this scope

Check failure

Code scanning / clippy

cannot find macro metrics in this scope Error

cannot find macro metrics in this scope

Check failure

Code scanning / clippy

cannot find macro metrics in this scope Error

cannot find macro metrics in this scope

Check failure

Code scanning / clippy

cannot find macro metrics in this scope Error

cannot find macro metrics in this scope
{ $( $tt:tt )* } => { $( $tt )* }
}

#[cfg(not(feature = "metrics"))]
macro_rules! metrics {
macro_rules! metric {
{ $( $tt:tt)* } => {}
}

pub(crate) use metrics;
pub(crate) use metric;

use core::fmt::Debug;
use core::ops::Deref;
Expand Down
2 changes: 1 addition & 1 deletion src/net/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Listener {
pub fn accept(&self) -> Result<Stream> {
let result = self._accept();

metrics! {
metric! {
STREAM_ACCEPT.increment();

if result.is_err() {
Expand Down
4 changes: 2 additions & 2 deletions src/net/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Stream {
StreamType::TlsTcp(s) => s.shutdown().map(|v| v == ShutdownResult::Received),
};

metrics! {
metric! {
STREAM_SHUTDOWN.increment();

if result.is_err() {
Expand All @@ -96,7 +96,7 @@ impl Stream {

impl Drop for Stream {
fn drop(&mut self) {
metrics! {
metric! {
STREAM_CLOSE.increment();
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/net/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl TcpStream {
pub fn connect(addr: SocketAddr) -> Result<Self> {
let inner = mio::net::TcpStream::connect(addr)?;

metrics! {
metric! {
TCP_CONN_CURR.increment();
TCP_CONNECT.increment();
}
Expand Down Expand Up @@ -60,7 +60,7 @@ impl TcpStream {

impl Drop for TcpStream {
fn drop(&mut self) {
metrics! {
metric! {
TCP_CONN_CURR.decrement();
TCP_CLOSE.increment();
}
Expand All @@ -85,7 +85,7 @@ impl Read for TcpStream {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
match self.inner.read(buf) {
Ok(amt) => {
metrics! {
metric! {
TCP_RECV_BYTE.add(amt as _);
}

Expand All @@ -100,7 +100,7 @@ impl Write for TcpStream {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
match self.inner.write(buf) {
Ok(amt) => {
metrics! {
metric! {
TCP_SEND_BYTE.add(amt as _);
}

Expand Down Expand Up @@ -188,7 +188,7 @@ impl TcpListener {
)
});

metrics! {
metric! {
if result.is_ok() {
TCP_ACCEPT.increment();
TCP_CONN_CURR.increment();
Expand Down

0 comments on commit 24f58bf

Please sign in to comment.