Skip to content

Commit

Permalink
Added headers to source message
Browse files Browse the repository at this point in the history
Signed-off-by: shubham <[email protected]>
  • Loading branch information
shubhamdixit863 committed May 28, 2024
1 parent 2483003 commit 085d3a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions examples/simple-source/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ pub(crate) mod simple_source {
self.read_idx
.store(self.read_idx.load(Ordering::Relaxed) + 1, Ordering::Relaxed);
let offset = self.read_idx.load(Ordering::Relaxed);

let mut headers=HashMap::new();
headers.insert(String::from("key"),String::from("key"));
// send the message to the transmitter
transmitter
.send(Message {
Expand All @@ -64,7 +65,7 @@ pub(crate) mod simple_source {
},
event_time: chrono::offset::Utc::now(),
keys: vec![],
headers:HashMap::new().insert("key","key")
headers:headers.clone()
})
.await
.unwrap();
Expand Down
5 changes: 4 additions & 1 deletion src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl<T> Server<T> {
mod tests {
use super::proto;
use chrono::Utc;
use std::collections::HashSet;
use std::collections::{HashMap, HashSet};
use std::vec;
use std::{error::Error, time::Duration};
use tokio_stream::StreamExt;
Expand Down Expand Up @@ -323,6 +323,8 @@ mod tests {
async fn read(&self, request: SourceReadRequest, transmitter: Sender<Message>) {
let event_time = Utc::now();
let mut message_offsets = Vec::with_capacity(request.count);
let mut headers=HashMap::new();
headers.insert(String::from("key"),String::from("key"));
for i in 0..request.count {
// we assume timestamp in nanoseconds would be unique on each read operation from our source
let offset = format!("{}-{}", event_time.timestamp_nanos_opt().unwrap(), i);
Expand All @@ -335,6 +337,7 @@ mod tests {
partition_id: 0,
},
keys: vec![],
headers:headers.clone(),
})
.await
.unwrap();
Expand Down

0 comments on commit 085d3a6

Please sign in to comment.