feat: adds trace events to server

This commit is contained in:
Avery Harnish
2020-03-03 12:31:49 -06:00
parent 80511f2cb5
commit 2b6b19ebc3
7 changed files with 651 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ use crate::{Connection, Frame, Kv};
use bytes::Bytes;
use std::io;
use std::time::Duration;
use tracing::{debug, instrument};
#[derive(Debug)]
pub struct Set {
@@ -13,6 +14,7 @@ pub struct Set {
}
impl Set {
#[instrument]
pub(crate) fn parse(parse: &mut Parse) -> Result<Set, ParseError> {
use ParseError::EndOfStream;
@@ -34,14 +36,18 @@ impl Set {
Err(err) => return Err(err),
}
debug!(?key, ?value, ?expire);
Ok(Set { key, value, expire })
}
#[instrument]
pub(crate) async fn apply(self, kv: &Kv, dst: &mut Connection) -> io::Result<()> {
// Set the value
kv.set(self.key, self.value, self.expire);
let response = Frame::Simple("OK".to_string());
debug!(?response);
dst.write_frame(&response).await
}
}