#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Direction {
Inbound,
Outbound,
}
impl Direction {
pub fn as_str(self) -> &'static str {
match self {
Self::Inbound => "inbound",
Self::Outbound => "outbound",
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TransportRejection {
SendError,
DrainRejected,
DecodeError,
RouteFailed,
MissingHeaders,
MissingType,
InvalidType,
InvalidHeaderLength,
TruncatedFrame,
DrainReplyBuildFailed,
}
impl TransportRejection {
pub fn as_str(self) -> &'static str {
match self {
Self::SendError => "send_error",
Self::DrainRejected => "drain_rejected",
Self::DecodeError => "decode_error",
Self::RouteFailed => "route_failed",
Self::MissingHeaders => "missing_headers",
Self::MissingType => "missing_type",
Self::InvalidType => "invalid_type",
Self::InvalidHeaderLength => "invalid_header_length",
Self::TruncatedFrame => "truncated_frame",
Self::DrainReplyBuildFailed => "drain_reply_build_failed",
}
}
}
pub trait TransportObservability: Send + Sync {
fn record_frame(&self, direction: Direction, message_type: &str, bytes: usize);
fn record_rejection(&self, reason: TransportRejection);
fn set_registered_peers(&self, count: usize);
fn set_active_connections(&self, count: usize);
fn record_send_backpressure(&self);
}