Skip to content

Commit 148d9f3

Browse files
committed
rename method and update comment
1 parent 8df55f0 commit 148d9f3

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

bottlecap/src/lifecycle/invocation/triggers/msk_event.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ fn bytes_from_header_value(val: &Value) -> Option<Vec<u8>> {
5555
}
5656
}
5757

58-
/// Extracts trace propagation headers from an MSK record's `headers` field into a carrier map.
59-
/// The `headers` field is a JSON object with numeric string keys, one entry per Kafka header.
60-
fn carrier_from_headers(headers: &Value) -> HashMap<String, String> {
58+
/// Decodes an MSK record's `headers` field into a `HashMap<String, String>` by converting
59+
/// each header's byte values to a UTF-8 string. The `headers` field may be either a JSON
60+
/// array or a JSON object with numeric string keys, one entry per Kafka header, ordered by index.
61+
fn headers_to_string_map(headers: &Value) -> HashMap<String, String> {
6162
let mut carrier = HashMap::new();
6263

6364
let entries: Vec<&Value> = match headers {
@@ -185,7 +186,7 @@ impl Trigger for MSKEvent {
185186
self.records
186187
.values()
187188
.find_map(|arr| arr.first())
188-
.map_or_else(HashMap::new, |record| carrier_from_headers(&record.headers))
189+
.map_or_else(HashMap::new, |record| headers_to_string_map(&record.headers))
189190
}
190191

191192
fn is_async(&self) -> bool {

0 commit comments

Comments
 (0)