-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(firehose sink): implement partial failure retry (draft! for discussion only at this point) #16703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(firehose sink): implement partial failure retry (draft! for discussion only at this point) #16703
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| use super::{KinesisClient, KinesisError, KinesisRecord, Record, SendRecord}; | ||
| use aws_sdk_firehose::error::PutRecordBatchError; | ||
| use aws_sdk_firehose::output::PutRecordBatchOutput; | ||
| use aws_sdk_firehose::types::{Blob, SdkError}; | ||
| use bytes::Bytes; | ||
| #[cfg(not(test))] | ||
| use tokio::time::{sleep, Duration}; | ||
| use tracing::Instrument; | ||
|
|
||
| use super::{KinesisClient, KinesisError, KinesisRecord, Record, SendRecord}; | ||
|
|
||
| #[derive(Clone)] | ||
| pub struct KinesisFirehoseRecord { | ||
| pub record: KinesisRecord, | ||
|
|
@@ -47,13 +50,49 @@ impl SendRecord for KinesisFirehoseClient { | |
| type E = KinesisError; | ||
|
|
||
| async fn send(&self, records: Vec<Self::T>, stream_name: String) -> Option<SdkError<Self::E>> { | ||
| let mut r = self.inner_send(records.clone(), stream_name.clone()).await; | ||
|
|
||
| for _ in 1..=3 { | ||
| if let Ok(resp) = &r { | ||
| if resp.failed_put_count().unwrap_or(0) > 0 { | ||
| #[cfg(not(test))] // the wait fails during test for some reason. | ||
| sleep(Duration::from_millis(100)).await; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't any configuration or backoff at all. Really, just an example at this point to hopefully get some eyes/input. |
||
|
|
||
| let mut failed_records = vec![]; | ||
| let itr = records | ||
| .clone() | ||
| .into_iter() | ||
| .zip(resp.request_responses().unwrap().into_iter()); | ||
| for (rec, response) in itr { | ||
| // TODO can just filter | ||
| if response.error_code().is_some() { | ||
| failed_records.push(rec.clone()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all kinds of cloning and unidiomatic rust - this is just an example for now. |
||
| } | ||
| } | ||
|
|
||
| r = self.inner_send(failed_records, stream_name.clone()).await; | ||
| } else { | ||
| return r.err(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return r.err(); | ||
| } | ||
| } | ||
|
|
||
| impl KinesisFirehoseClient { | ||
| async fn inner_send( | ||
| &self, | ||
| records: Vec<KinesisRecord>, | ||
| stream_name: String, | ||
| ) -> Result<PutRecordBatchOutput, SdkError<PutRecordBatchError>> { | ||
| self.client | ||
| .put_record_batch() | ||
| .set_records(Some(records)) | ||
| .delivery_stream_name(stream_name) | ||
| .send() | ||
| .instrument(info_span!("request").or_current()) | ||
| .await | ||
| .err() | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of odd, but I noticed that the tokio sleep causes a test failure, even if it isn't executed.