forked from rustfixbot/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement more introspection commands and CreateUploadPlaybackStream
- Loading branch information
Showing
12 changed files
with
341 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use crate::protocol::{serde::*, ProtocolError}; | ||
|
||
use super::CommandReply; | ||
|
||
/// The server response to [`super::Command::LookupSource`] and [`super::Command::LookupSink`]. | ||
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)] | ||
pub struct LookupReply(u32); | ||
|
||
impl CommandReply for LookupReply {} | ||
|
||
impl TagStructRead for LookupReply { | ||
fn read(ts: &mut TagStructReader<'_>, _protocol_version: u16) -> Result<Self, ProtocolError> { | ||
Ok(Self(ts.read_u32()?)) | ||
} | ||
} | ||
|
||
impl TagStructWrite for LookupReply { | ||
fn write( | ||
&self, | ||
w: &mut TagStructWriter<'_>, | ||
_protocol_version: u16, | ||
) -> Result<(), ProtocolError> { | ||
w.write_u32(self.0)?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
use crate::protocol::{serde::*, ProtocolError}; | ||
|
||
use super::CommandReply; | ||
|
||
/// A reply to the [`super::Command::Stat`] command. | ||
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] | ||
pub struct StatInfo { | ||
/// The number of currently allocated memory blocks. | ||
pub memblock_total: u32, | ||
/// The current total size of all allocated memory blocks. | ||
pub memblock_total_size: u32, | ||
/// The number of memblocks allocated over the lifetime of the daemon. | ||
pub memblock_allocated: u32, | ||
/// The total size of all memblocks allocated over the lifetime of the daemon. | ||
pub memblock_allocated_size: u32, | ||
/// The total size of all sample cache entries. | ||
pub sample_cache_size: u32, | ||
} | ||
|
||
impl CommandReply for StatInfo {} | ||
|
||
impl TagStructRead for StatInfo { | ||
fn read(ts: &mut TagStructReader<'_>, _protocol_version: u16) -> Result<Self, ProtocolError> { | ||
Ok(Self { | ||
memblock_total: ts.read_u32()?, | ||
memblock_total_size: ts.read_u32()?, | ||
memblock_allocated: ts.read_u32()?, | ||
memblock_allocated_size: ts.read_u32()?, | ||
sample_cache_size: ts.read_u32()?, | ||
}) | ||
} | ||
} | ||
|
||
impl TagStructWrite for StatInfo { | ||
fn write( | ||
&self, | ||
w: &mut TagStructWriter<'_>, | ||
_protocol_version: u16, | ||
) -> Result<(), ProtocolError> { | ||
w.write_u32(self.memblock_total)?; | ||
w.write_u32(self.memblock_total_size)?; | ||
w.write_u32(self.memblock_allocated)?; | ||
w.write_u32(self.memblock_allocated_size)?; | ||
w.write_u32(self.sample_cache_size)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::protocol::test_util::test_serde; | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn stat_serde() -> anyhow::Result<()> { | ||
let info = StatInfo { | ||
memblock_total: 1, | ||
memblock_total_size: 2, | ||
memblock_allocated: 3, | ||
memblock_allocated_size: 4, | ||
sample_cache_size: 5, | ||
}; | ||
|
||
test_serde(&info) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
#[cfg(feature = "_integration-tests")] | ||
mod integration_tests { | ||
use crate::{integration_test_util::connect_and_init, protocol::*}; | ||
|
||
#[test] | ||
fn stat() -> Result<(), Box<dyn std::error::Error>> { | ||
let (mut sock, protocol_version) = connect_and_init()?; | ||
|
||
write_command_message(sock.get_mut(), 0, Command::Stat, protocol_version)?; | ||
let (_, info) = read_reply_message::<StatInfo>(&mut sock)?; | ||
|
||
assert!(info.memblock_total > 0); | ||
assert!(info.memblock_total_size > 0); | ||
assert!(info.memblock_allocated > 0); | ||
assert!(info.memblock_allocated_size > 0); | ||
|
||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.