Skip to content

Commit 2e6f97b

Browse files
authored
Merge pull request #38 from ilikepi63/chore/removed-noisy-logging
chore: Removed Noisy Logging
2 parents 6e91c5c + c58708e commit 2e6f97b

File tree

11 files changed

+140
-186
lines changed

11 files changed

+140
-186
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "riskless"
3-
version = "0.6.1"
3+
version = "0.6.2"
44
edition = "2024"
55
description = "A pure Rust implementation of Diskless Topics"
66
license = "MIT / Apache-2.0"

examples/concurrent.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use tokio::sync::RwLock;
1010
#[tokio::main]
1111
async fn main() {
1212
let object_store =
13-
Arc::new(object_store::local::LocalFileSystem::new_with_prefix("data").unwrap());
13+
Arc::new(object_store::local::LocalFileSystem::new_with_prefix("data").expect(""));
1414
let batch_coordinator = Arc::new(SimpleBatchCoordinator::new("index".to_string()));
1515

1616
let col = Arc::new(RwLock::new(ProduceRequestCollection::new()));
@@ -27,7 +27,7 @@ async fn main() {
2727
partition: 1,
2828
data: "hello".as_bytes().to_vec(),
2929
})
30-
.unwrap();
30+
.expect("");
3131
});
3232

3333
let col_flush = col.clone();
@@ -45,7 +45,7 @@ async fn main() {
4545

4646
let produce_response = flush(new_ref, flush_object_store_ref, flush_batch_coord_ref)
4747
.await
48-
.unwrap();
48+
.expect("");
4949

5050
assert_eq!(produce_response.len(), 1);
5151
});
@@ -66,7 +66,7 @@ async fn main() {
6666

6767
assert!(consume_response.is_ok());
6868

69-
let mut resp = consume_response.unwrap();
69+
let mut resp = consume_response.expect("");
7070
let batch = resp.recv().await;
7171

7272
println!("Batch: {:#?}", batch);

examples/simple.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use riskless::{
99
#[tokio::main]
1010
async fn main() {
1111
let object_store =
12-
Arc::new(object_store::local::LocalFileSystem::new_with_prefix("data").unwrap());
12+
Arc::new(object_store::local::LocalFileSystem::new_with_prefix("data").expect(""));
1313
let batch_coordinator = Arc::new(SimpleBatchCoordinator::new("index".to_string()));
1414

1515
let col = ProduceRequestCollection::new();
@@ -20,11 +20,11 @@ async fn main() {
2020
partition: 1,
2121
data: "hello".as_bytes().to_vec(),
2222
})
23-
.unwrap();
23+
.expect("");
2424

2525
let produce_response = flush(col, object_store.clone(), batch_coordinator.clone())
2626
.await
27-
.unwrap();
27+
.expect("");
2828

2929
assert_eq!(produce_response.len(), 1);
3030

@@ -40,7 +40,7 @@ async fn main() {
4040
)
4141
.await;
4242

43-
let mut resp = consume_response.unwrap();
43+
let mut resp = consume_response.expect("");
4444
let batch = resp.recv().await;
4545

4646
println!("Batch: {:#?}", batch);

src/batch_coordinator/simple/index.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@ impl TryFrom<&[u8]> for Index {
4040
return Err(RisklessError::Unknown); // TODO make an error for this.;
4141
}
4242

43-
tracing::info!("{:#?}", &value[0..16]);
44-
4543
let object_key = Uuid::from_slice(&value[0..16])?;
4644

47-
tracing::info!("{:#?}", &value[17..24]);
48-
4945
let offset = u64::from_be_bytes(value[16..24].try_into()?);
5046

5147
let size = u32::from_be_bytes(value[24..28].try_into()?);
@@ -100,8 +96,11 @@ mod tests {
10096
// Check the written bytes
10197
assert_eq!(buf.len(), 16 + 8 + 4); // UUID + u64 + u32
10298
assert_eq!(&buf[0..16], uuid.as_bytes());
103-
assert_eq!(u64::from_be_bytes(buf[16..24].try_into().unwrap()), offset);
104-
assert_eq!(u32::from_be_bytes(buf[24..28].try_into().unwrap()), size);
99+
assert_eq!(
100+
u64::from_be_bytes(buf[16..24].try_into().expect("")),
101+
offset
102+
);
103+
assert_eq!(u32::from_be_bytes(buf[24..28].try_into().expect("")), size);
105104
}
106105

107106
#[test]
@@ -115,9 +114,7 @@ mod tests {
115114
bytes.extend_from_slice(&offset.to_be_bytes());
116115
bytes.extend_from_slice(&size.to_be_bytes());
117116

118-
tracing::info!("{:#?}", bytes);
119-
120-
let index = Index::try_from(bytes.as_slice()).unwrap();
117+
let index = Index::try_from(bytes.as_slice()).expect("");
121118

122119
assert_eq!(index.object_key, uuid);
123120
assert_eq!(index.offset, offset);
@@ -130,8 +127,6 @@ mod tests {
130127

131128
let result = Index::try_from(bytes.as_slice());
132129

133-
tracing::info!("{:#?}", result);
134-
135130
assert!(result.is_err());
136131
}
137132

@@ -148,7 +143,7 @@ mod tests {
148143
let mut buf = BytesMut::new();
149144
original_clone.write(&mut buf);
150145

151-
let reconstructed = Index::try_from(buf.as_ref()).unwrap();
146+
let reconstructed = Index::try_from(buf.as_ref()).expect("");
152147

153148
assert_eq!(reconstructed.object_key, original.object_key);
154149
assert_eq!(reconstructed.offset, original.offset);

src/batch_coordinator/simple/mod.rs

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ impl SimpleBatchCoordinator {
6666

6767
/// Opens or creates the underlying file depending on it's existence.
6868
fn open_or_create_file(current_partition_file: &PathBuf) -> RisklessResult<File> {
69-
tracing::info!("File {:#?} exists.", current_partition_file);
70-
7169
let file = match current_partition_file.exists() {
7270
true => {
7371
let mut open_opts = OpenOptions::new();
@@ -76,14 +74,8 @@ impl SimpleBatchCoordinator {
7674

7775
open_opts.open(current_partition_file)
7876
}
79-
false => {
80-
tracing::info!("Actually doing this..");
81-
std::fs::File::create(current_partition_file)
82-
}
77+
false => std::fs::File::create(current_partition_file),
8378
};
84-
85-
tracing::info!("Result from file: {:#?}", file);
86-
8779
Ok(file?)
8880
}
8981

@@ -118,8 +110,6 @@ impl CommitFile for SimpleBatchCoordinator {
118110

119111
let file = Self::open_or_create_file(current_partition_file);
120112

121-
tracing::info!("Result from file: {:#?}", file);
122-
123113
match file {
124114
Ok(mut file) => {
125115
let offset = batch.byte_offset;
@@ -148,8 +138,6 @@ impl CommitFile for SimpleBatchCoordinator {
148138
is_duplicate: false,
149139
request: batch,
150140
});
151-
tracing::info!("Error when creating index file: {:#?}", err);
152-
// TODO: File error and return to result.
153141
}
154142
}
155143
}
@@ -181,8 +169,6 @@ impl FindBatches for SimpleBatchCoordinator {
181169

182170
match file {
183171
Ok(mut file) => {
184-
tracing::info!("Reading from position: {:#?}", request.offset);
185-
186172
let size_in_u64: u64 = match Index::packed_size().try_into() {
187173
Ok(s) => s,
188174
Err(err) => {
@@ -246,8 +232,6 @@ impl FindBatches for SimpleBatchCoordinator {
246232

247233
match index {
248234
Ok(index) => {
249-
tracing::info!("Received Index: {:#?}", index);
250-
251235
results.push(FindBatchResponse {
252236
errors: vec![],
253237
batches: vec![BatchInfo {
@@ -282,10 +266,7 @@ impl FindBatches for SimpleBatchCoordinator {
282266
}
283267
}
284268
}
285-
Err(err) => {
286-
tracing::info!("Error when creating index file: {:#?}", err);
287-
// TODO: File error and return to result.
288-
}
269+
Err(_err) => {}
289270
}
290271
}
291272

@@ -338,13 +319,13 @@ mod tests {
338319
fn set_up_dirs() -> PathBuf {
339320
let mut batch_coord_path = std::env::temp_dir();
340321
batch_coord_path.push(uuid::Uuid::new_v4().to_string());
341-
std::fs::create_dir(&batch_coord_path).unwrap();
322+
std::fs::create_dir(&batch_coord_path).expect("");
342323

343324
batch_coord_path
344325
}
345326

346327
fn tear_down_dirs(batch_coord: PathBuf) {
347-
std::fs::remove_dir_all(&batch_coord).unwrap();
328+
std::fs::remove_dir_all(&batch_coord).expect("");
348329
}
349330

350331
#[test]
@@ -361,7 +342,7 @@ mod tests {
361342
fn test_topic_dir_creates_directory_if_not_exists() {
362343
let temp_dir = set_up_dirs();
363344

364-
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().unwrap().to_string());
345+
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().expect("").to_string());
365346

366347
let topic = "test_topic".to_string();
367348

@@ -383,13 +364,13 @@ mod tests {
383364
fn test_topic_dir_uses_existing_directory() {
384365
let temp_dir = set_up_dirs();
385366

386-
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().unwrap().to_string());
367+
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().expect("").to_string());
387368

388369
let topic = "existing_topic".to_string();
389370

390371
// Create the directory manually first
391372
let expected_path = temp_dir.join(&topic);
392-
fs::create_dir(&expected_path).unwrap();
373+
fs::create_dir(&expected_path).expect("");
393374

394375
// Call topic_dir
395376
let result = coordinator.topic_dir(topic.clone());
@@ -408,7 +389,7 @@ mod tests {
408389
SimpleBatchCoordinator::partition_index_file_from_topic_dir(&mut topic_dir, partition);
409390

410391
assert_eq!(
411-
result.to_str().unwrap(),
392+
result.to_str().expect(""),
412393
"test_topic/00000000000000000042.index"
413394
);
414395
}
@@ -437,7 +418,7 @@ mod tests {
437418
let file_path = temp_dir.join("existing_file.index");
438419

439420
// Create the file first
440-
File::create(&file_path).unwrap();
421+
File::create(&file_path).expect("");
441422

442423
// Try to open
443424
let result = SimpleBatchCoordinator::open_or_create_file(&file_path);
@@ -451,7 +432,7 @@ mod tests {
451432
let file_path = temp_dir.join("test_open_file.index");
452433

453434
// Create the file first
454-
File::create(&file_path).unwrap();
435+
File::create(&file_path).expect("");
455436

456437
// Try to open
457438
let result = SimpleBatchCoordinator::open_file(&file_path);
@@ -475,7 +456,7 @@ mod tests {
475456
async fn test_commit_file_creates_index_file() {
476457
let temp_dir = set_up_dirs();
477458

478-
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().unwrap().to_string());
459+
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().expect("").to_string());
479460

480461
let whole_dir = temp_dir.clone();
481462

@@ -508,18 +489,13 @@ mod tests {
508489
// Commit the file
509490
coordinator.commit_file(object_key, 1, 100, batches).await;
510491

511-
tracing::info!(
512-
"{:#?}",
513-
std::fs::read_dir(&whole_dir).unwrap().collect::<Vec<_>>()
514-
);
515-
516492
// File should now exist
517493
assert!(expected_file_path.exists());
518494

519495
// Verify file contents
520-
let mut file = File::open(&expected_file_path).unwrap();
496+
let mut file = File::open(&expected_file_path).expect("");
521497
let mut buf = [0u8; 28]; // Assuming Index is 28 bytes
522-
file.read_exact(&mut buf).unwrap();
498+
file.read_exact(&mut buf).expect("");
523499

524500
// You might want to add more specific assertions about the contents
525501
assert_ne!(buf, [0u8; 28]);
@@ -530,7 +506,7 @@ mod tests {
530506
async fn test_find_batches_reads_correct_data() -> Result<(), Box<dyn std::error::Error>> {
531507
let temp_dir = set_up_dirs();
532508

533-
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().unwrap().to_string());
509+
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().expect("").to_string());
534510

535511
// TODO: This behaviour likely needs to be implemented in the SimpleBatchCoordinator.
536512
let data_path = temp_dir.clone();
@@ -594,7 +570,7 @@ mod tests {
594570
async fn test_multiple_writes() -> Result<(), Box<dyn std::error::Error>> {
595571
let temp_dir = set_up_dirs();
596572

597-
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().unwrap().to_string());
573+
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().expect("").to_string());
598574

599575
// TODO: This behaviour likely needs to be implemented in the SimpleBatchCoordinator.
600576
let data_path = temp_dir.clone();
@@ -673,12 +649,8 @@ mod tests {
673649

674650
index_path.push(&topic);
675651

676-
tracing::info!("{:#?}", std::fs::read_dir(&index_path)?.collect::<Vec<_>>());
677-
678652
index_path.push(format!("{:0>20}.index", partition.to_string()));
679653

680-
tracing::info!("{:#?}", index_path);
681-
682654
let data = std::fs::read(index_path)?;
683655

684656
assert_eq!(data.len(), Index::packed_size() * 3);
@@ -731,7 +703,7 @@ mod tests {
731703
async fn test_find_batches_handles_missing_file() {
732704
let temp_dir = set_up_dirs();
733705

734-
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().unwrap().to_string());
706+
let coordinator = SimpleBatchCoordinator::new(temp_dir.to_str().expect("").to_string());
735707

736708
let find_requests = vec![FindBatchRequest {
737709
topic_id_partition: TopicIdPartition("nonexistent_topic".to_string(), 1),

src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ pub async fn flush(
7676
object_storage: Arc<dyn ObjectStore>,
7777
batch_coordinator: Arc<dyn CommitFile>,
7878
) -> RisklessResult<Vec<ProduceResponse>> {
79-
tracing::info!("Produce Requests: {:#?}", reqs);
80-
8179
let reqs: SharedLogSegment = reqs.try_into()?;
8280

8381
let batch_coords = reqs.get_batch_coords().clone();
@@ -109,16 +107,13 @@ pub async fn flush(
109107
)
110108
.await;
111109

112-
tracing::info!("Put Result: {:#?}", put_result);
113-
114110
Ok(put_result
115111
.iter()
116112
.map(ProduceResponse::from)
117113
.collect::<Vec<_>>())
118114
}
119115

120116
/// Handles a consume request by retrieving messages from object storage.
121-
#[tracing::instrument(skip_all, name = "consume")]
122117
pub async fn consume(
123118
request: ConsumeRequest,
124119
object_storage: Arc<dyn ObjectStore>,
@@ -159,8 +154,6 @@ pub async fn consume(
159154
let result = match get_object_result {
160155
Ok(get_result) => {
161156
if let Ok(b) = get_result.bytes().await {
162-
tracing::info!("Retrieved Bytes: {:#?}", b);
163-
164157
// Retrieve the current fetch Responses by name.
165158
let batch_responses_for_object = batch_responses
166159
.iter()

src/messages/consume_response.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ impl TryFrom<(FindBatchResponse, &BatchInfo, &Bytes)> for ConsumeBatch {
4242
+ Into::<u64>::into(batch_info.metadata.byte_size))
4343
.try_into()?;
4444

45-
tracing::info!("START: {} END: {} ", start, end);
46-
4745
let data = bytes.slice(start..end);
4846

4947
let batch = ConsumeBatch {

0 commit comments

Comments
 (0)