diff --git a/Cargo.lock b/Cargo.lock
index 01e8d0d..06ffca7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4304,6 +4304,7 @@ dependencies = [
"nom 8.0.0-alpha2",
"thiserror",
"tokio",
+ "tracing",
]
[[package]]
diff --git a/crates/synd_kvsd_protocol/Cargo.toml b/crates/synd_kvsd_protocol/Cargo.toml
index 1e33234..2458be4 100644
--- a/crates/synd_kvsd_protocol/Cargo.toml
+++ b/crates/synd_kvsd_protocol/Cargo.toml
@@ -21,6 +21,7 @@ futures = { workspace = true }
nom = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["net", "time", "io-util"] }
+tracing = { workspace = true }
[dev-dependencies]
tokio = { workspace = true, features = ["net", "time", "io-util", "macros", "rt-multi-thread"] }
diff --git a/crates/synd_kvsd_protocol/src/connection.rs b/crates/synd_kvsd_protocol/src/connection.rs
index fa9902f..e91ecdd 100644
--- a/crates/synd_kvsd_protocol/src/connection.rs
+++ b/crates/synd_kvsd_protocol/src/connection.rs
@@ -3,7 +3,7 @@ use std::{
time::Duration,
};
-use bytes::{Buf as _, BytesMut};
+use bytes::{Buf, BytesMut};
use futures::TryFutureExt as _;
use thiserror::Error;
use tokio::{
@@ -11,8 +11,9 @@ use tokio::{
net::TcpStream,
time::error::Elapsed,
};
+use tracing::trace;
-use crate::message::{Cursor, FrameError, Message, MessageError, MessageFrames};
+use crate::message::{FrameError, Message, MessageError, ParseError, Parser};
#[derive(Error, Debug)]
pub enum ConnectionError {
@@ -24,6 +25,8 @@ pub enum ConnectionError {
ParseMessageFrames { source: FrameError },
#[error("read message io: {source}")]
ReadMessageIo { source: io::Error },
+ #[error("parse message: {0}")]
+ ParseMessage(#[from] ParseError),
#[error("connection reset by peer")]
ResetByPeer,
#[error("write message: {source}")]
@@ -35,14 +38,6 @@ impl ConnectionError {
ConnectionError::ReadTimeout(elapsed)
}
- fn read_message_frames(source: MessageError) -> Self {
- ConnectionError::ReadMessageFrames { source }
- }
-
- fn parse_message_frames(source: FrameError) -> Self {
- ConnectionError::ParseMessageFrames { source }
- }
-
fn read_message_io(source: io::Error) -> Self {
ConnectionError::ReadMessageIo { source }
}
@@ -102,54 +97,36 @@ where
}
pub async fn read_message(&mut self) -> Result