refactor: replace std::sync::mpsc with flume for improved channel performance

Migrate internal message passing to flume to leverage better performance and additional features like eventual fairness and selection.
This commit is contained in:
Nils Andreas Svee committed 2026-04-22 22:39:06 +07:00
1 parent ea19c6d68b
commit 3322e82b6c
8 files changed
+159 -12

No files matched your search

+3 -3
View File
@@ -1,13 +1,13 @@
use crate::Config;
use crate::config::{MeasurementType, ObservabilityProtocol};
use crate::time::Time;
use flume::{Receiver, RecvTimeoutError, Sender};
use log::{error, info, warn};
use rustix::time::ClockId;
use std::fmt::Write;
use std::net::{IpAddr, TcpStream, UdpSocket};
use std::sync::Arc;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::mpsc::{Receiver, RecvTimeoutError, SyncSender};
use std::time::Duration;
const MAX_RECONNECT_BACKOFF: u64 = 60;
@@ -122,12 +122,12 @@ pub enum Metric {
#[derive(Clone)]
pub struct MetricsSender {
tx: Option<SyncSender<(Metric, u64)>>,
tx: Option<Sender<(Metric, u64)>>,
dropped: Arc<AtomicU32>,
}
impl MetricsSender {
pub fn new(tx: SyncSender<(Metric, u64)>, dropped: Arc<AtomicU32>) -> Self {
pub fn new(tx: Sender<(Metric, u64)>, dropped: Arc<AtomicU32>) -> Self {
Self {
tx: Some(tx),
dropped,