From d3d0a3cd9f5c3464fc3fb81c6f7488875cd2a145 Mon Sep 17 00:00:00 2001 From: boqiu <82121246@qq.com> Date: Thu, 22 Aug 2024 10:04:31 +0800 Subject: [PATCH] refactor channel receiver --- common/channel/src/channel.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/common/channel/src/channel.rs b/common/channel/src/channel.rs index 1c70df9..a2df646 100644 --- a/common/channel/src/channel.rs +++ b/common/channel/src/channel.rs @@ -3,7 +3,6 @@ use crate::metrics::unbounded_channel; use metrics::{Counter, CounterUsize}; use std::sync::Arc; use std::time::Duration; -use tokio::sync::mpsc::error::TryRecvError; use tokio::sync::oneshot; use tokio::time::timeout; @@ -31,7 +30,7 @@ impl Channel { chan: sender, metrics_timeout, }, - Receiver { chan: receiver }, + receiver, ) } } @@ -74,19 +73,7 @@ impl Sender { } } -pub struct Receiver { - chan: crate::metrics::Receiver>, -} - -impl Receiver { - pub async fn recv(&mut self) -> Option> { - self.chan.recv().await - } - - pub fn try_recv(&mut self) -> Result, TryRecvError> { - self.chan.try_recv() - } -} +pub type Receiver = crate::metrics::Receiver>; #[cfg(test)] mod tests {