Replace log_err
with trace_err
on collab::rpc
This commit is contained in:
parent
1fe964ac16
commit
b51a53addb
1 changed files with 26 additions and 3 deletions
|
@ -47,7 +47,6 @@ use tokio::{
|
||||||
};
|
};
|
||||||
use tower::ServiceBuilder;
|
use tower::ServiceBuilder;
|
||||||
use tracing::{info_span, instrument, Instrument};
|
use tracing::{info_span, instrument, Instrument};
|
||||||
use util::ResultExt;
|
|
||||||
|
|
||||||
type MessageHandler =
|
type MessageHandler =
|
||||||
Box<dyn Send + Sync + Fn(Arc<Server>, Box<dyn AnyTypedEnvelope>) -> BoxFuture<'static, ()>>;
|
Box<dyn Send + Sync + Fn(Arc<Server>, Box<dyn AnyTypedEnvelope>) -> BoxFuture<'static, ()>>;
|
||||||
|
@ -875,7 +874,7 @@ impl Server {
|
||||||
contacts: contacts.clone(),
|
contacts: contacts.clone(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.log_err();
|
.trace_err();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1110,13 +1109,14 @@ impl Executor for RealExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(f))]
|
||||||
fn broadcast<F>(sender_id: ConnectionId, receiver_ids: Vec<ConnectionId>, mut f: F)
|
fn broadcast<F>(sender_id: ConnectionId, receiver_ids: Vec<ConnectionId>, mut f: F)
|
||||||
where
|
where
|
||||||
F: FnMut(ConnectionId) -> anyhow::Result<()>,
|
F: FnMut(ConnectionId) -> anyhow::Result<()>,
|
||||||
{
|
{
|
||||||
for receiver_id in receiver_ids {
|
for receiver_id in receiver_ids {
|
||||||
if receiver_id != sender_id {
|
if receiver_id != sender_id {
|
||||||
f(receiver_id).log_err();
|
f(receiver_id).trace_err();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1217,6 +1217,29 @@ fn to_tungstenite_message(message: AxumMessage) -> TungsteniteMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait ResultExt {
|
||||||
|
type Ok;
|
||||||
|
|
||||||
|
fn trace_err(self) -> Option<Self::Ok>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T, E> ResultExt for Result<T, E>
|
||||||
|
where
|
||||||
|
E: std::fmt::Debug,
|
||||||
|
{
|
||||||
|
type Ok = T;
|
||||||
|
|
||||||
|
fn trace_err(self) -> Option<T> {
|
||||||
|
match self {
|
||||||
|
Ok(value) => Some(value),
|
||||||
|
Err(error) => {
|
||||||
|
tracing::error!("{:?}", error);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue