Skip to content

Commit

Permalink
chore(sdk): update SendMessages Display
Browse files Browse the repository at this point in the history
This commit modifies the `Display` implementation for the
`SendMessages` struct to include batch length and batch size
in the output instead of raw payload data of message, so
stdout isn't overflown with useless data.
  • Loading branch information
hubcio committed Feb 17, 2025
1 parent f16afc8 commit 1b13493
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
8 changes: 4 additions & 4 deletions sdk/src/messages/send_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,15 @@ impl Display for SendMessages {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}|{}|{}|{}",
"{}|{}|{}|batch_len:{}|batch_size:{}",
self.stream_id,
self.topic_id,
self.partitioning,
self.messages.len(),
self.messages
.iter()
.map(std::string::ToString::to_string)
.collect::<Vec<String>>()
.join("|")
.map(Message::get_size_bytes)
.sum::<IggyByteSize>(),
)
}
}
Expand Down
23 changes: 14 additions & 9 deletions server/src/streaming/segments/logs/log_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ impl SegmentLogReader {

// posix_fadvise() doesn't exist on MacOS
#[cfg(not(target_os = "macos"))]
let _ = nix::fcntl::posix_fadvise(
fd,
0,
0,
nix::fcntl::PosixFadviseAdvice::POSIX_FADV_SEQUENTIAL,
)
.with_info_context(|e| {
format!("Failed to set sequential access pattern on log file: {file_path}, error: {e}")
});
{
let fd = file.as_raw_fd();
let _ = nix::fcntl::posix_fadvise(
fd,
0,
0,
nix::fcntl::PosixFadviseAdvice::POSIX_FADV_SEQUENTIAL,
)
.with_info_context(|e| {
format!(
"Failed to set sequential access pattern on log file: {file_path}, error: {e}"
)
});
}

let actual_log_size = file
.metadata()
Expand Down

0 comments on commit 1b13493

Please sign in to comment.