Skip to content

Commit 8dad4b4

Browse files
authored
fix(splunk_hec generator): Only require ack when acks enabled (#1215)
* fix(splunk_hec generator): Only require ack when acks enabled Signed-off-by: Jesse Szwedko <[email protected]> * Add changelog entry Signed-off-by: Jesse Szwedko <[email protected]> --------- Signed-off-by: Jesse Szwedko <[email protected]>
1 parent 576f3e0 commit 8dad4b4

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

CHANGELOG.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## Unreleased
8-
## Added
9-
- cgroup.v2 PSI metrics are now parsed.
7+
## [Unreleased]
8+
## Changed
9+
- The `splunk_hec` generator now only requires responses to have an `ackId` when
10+
`acknowledgements` are enabled.
11+
- cgroup.v2 PSI metrics are now parsed.
1012

1113
## [0.25.3]
1214
## Changed

lading/src/generator/splunk_hec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ where
352352
counter!("request_ok", &status_labels).increment(1);
353353
let body_bytes = body.boxed().collect().await?.to_bytes();
354354
let hec_ack_response =
355-
serde_json::from_slice::<HecAckResponse>(&body_bytes).expect("unable to parse response body");
355+
serde_json::from_slice::<HecResponse>(&body_bytes).expect("unable to parse response body");
356356
channel.send(ready(hec_ack_response.ack_id)).await?;
357357
}
358358
Err(err) => {
@@ -376,11 +376,11 @@ where
376376

377377
#[derive(Deserialize, Serialize, Debug)]
378378
#[serde(deny_unknown_fields)]
379-
struct HecAckResponse {
379+
struct HecResponse {
380380
#[allow(dead_code)]
381381
text: String,
382382
#[allow(dead_code)]
383383
code: u8,
384384
#[serde(rename = "ackId")]
385-
ack_id: u64,
385+
ack_id: Option<u64>,
386386
}

lading/src/generator/splunk_hec/acknowledgements.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ impl Channel {
5454

5555
pub(crate) async fn send<Fut>(&self, msg: Fut) -> Result<(), Error>
5656
where
57-
Fut: Future<Output = AckId>,
57+
Fut: Future<Output = Option<AckId>>,
5858
{
5959
match self {
6060
Self::NoAck { .. } => Ok(()),
61-
Self::Ack { tx, .. } => Ok(tx.send(msg.await).await?),
61+
Self::Ack { tx, .. } => Ok(tx
62+
.send(msg.await.expect("acknowledgemnts enabled, should have id"))
63+
.await?),
6264
}
6365
}
6466
}

0 commit comments

Comments
 (0)