add message terminator (newline) to socket writer output to ease client integration

This commit is contained in:
Sunny Gleason 2019-02-14 19:56:58 +00:00 committed by Grimes
parent c55ada2f26
commit 106645d9bd
1 changed files with 3 additions and 0 deletions

View File

@ -47,10 +47,13 @@ pub struct EntrySocket {
socket: String,
}
const MESSAGE_TERMINATOR: &str = "\n";
impl EntryWriter for EntrySocket {
fn write(&self, payload: String) -> Result<()> {
let mut socket = UnixStream::connect(Path::new(&self.socket))?;
socket.write_all(payload.as_bytes())?;
socket.write_all(MESSAGE_TERMINATOR.as_bytes())?;
socket.shutdown(Shutdown::Write)?;
Ok(())
}