-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(new sink): add AWS Simple Notification Service aws_sns sink
#18141
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
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
da4652f
ci: speed up tests by only running sqs tests
wochinge cd20a13
chore: prepare split in sqs and sns
wochinge 2b7ef02
chore: wrap up split for foundation
wochinge 6941cd0
refactor: separate config
wochinge 0ac39cb
refactor: implement separate publisher
wochinge f9e7148
refactor: drop no longer needed message builder
wochinge 891e119
refactor: extract error type
wochinge 8311045
style: name variable correctly
wochinge 8c4addd
feat: add sns 🎉
wochinge 5b42a29
refactor: abstract retry logic
wochinge b8bdc9c
chore: remove sqs from shared modules
wochinge 829db54
chore: cleanup
wochinge 36b0a59
chore: drop temporary changes
wochinge e76af5f
chore: update mod to include sns module
wochinge 6be88d4
refactor: move healthcheck out of config into separate function
wochinge 07e1938
refactor: simplify request builder setup
wochinge 14c2b67
refactor: message id
ArzelaAscoIi 0ed0b62
nit: make functions just visibile in sub module
ArzelaAscoIi 33c7c6f
fix: add pub(super)
ArzelaAscoIi d3b5a6a
fix: sub methods attributes pub(super)
ArzelaAscoIi 89c00c3
Update Cargo.toml
ArzelaAscoIi 4a641a3
Update src/sinks/aws_s_s/mod.rs
ArzelaAscoIi 129313c
Update src/sinks/aws_s_s/retry.rs
ArzelaAscoIi efdf844
Update src/sinks/mod.rs
ArzelaAscoIi e7fe94c
Update src/sinks/aws_s_s/sns/config.rs
ArzelaAscoIi a7c7cf7
chore: first bunch of comments
ArzelaAscoIi 8f3be55
Merge branch 'feat/sns' of github.com:wochinge/vector into feat/sns
ArzelaAscoIi 69890db
chore: second bunch of comments
ArzelaAscoIi 6a51b9e
chore: enable all integration tests
ArzelaAscoIi 345d147
fix: move test
ArzelaAscoIi 5308c0e
fix: dead_code warning
ArzelaAscoIi 4df0786
fix: dead code warning
ArzelaAscoIi a2223eb
docs: autogenerated aws_sns docs
ArzelaAscoIi 8dbb7be
fix: move region serde to downstream impl
ArzelaAscoIi 185fe20
update licenses
neuronull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| use super::{request_builder::SendMessageEntry, service::SendMessageResponse}; | ||
| use aws_sdk_sqs::types::SdkError; | ||
|
|
||
| #[async_trait::async_trait] | ||
| pub(super) trait Client<R> | ||
| where | ||
| R: std::fmt::Debug + std::fmt::Display + std::error::Error, | ||
| { | ||
| async fn send_message( | ||
| &self, | ||
| entry: SendMessageEntry, | ||
| byte_size: usize, | ||
| ) -> Result<SendMessageResponse, SdkError<R>>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| use std::convert::TryFrom; | ||
|
|
||
| use snafu::{ResultExt, Snafu}; | ||
|
|
||
| use vector_config::configurable_component; | ||
|
|
||
| use crate::{ | ||
| aws::AwsAuthentication, | ||
| codecs::EncodingConfig, | ||
| config::AcknowledgementsConfig, | ||
| sinks::util::TowerRequestConfig, | ||
| template::{Template, TemplateParseError}, | ||
| tls::TlsConfig, | ||
| }; | ||
|
|
||
| #[derive(Debug, Snafu)] | ||
| pub(super) enum BuildError { | ||
| #[snafu(display("`message_group_id` should be defined for FIFO queue."))] | ||
| MessageGroupIdMissing, | ||
| #[snafu(display("`message_group_id` is not allowed with non-FIFO queue."))] | ||
| MessageGroupIdNotAllowed, | ||
| #[snafu(display("invalid topic template: {}", source))] | ||
| TopicTemplate { source: TemplateParseError }, | ||
| #[snafu(display("invalid message_deduplication_id template: {}", source))] | ||
| MessageDeduplicationIdTemplate { source: TemplateParseError }, | ||
| } | ||
|
|
||
| /// Base Configuration `aws_s_s` for sns and sqs sink. | ||
| #[configurable_component] | ||
| #[derive(Clone, Debug)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub(super) struct BaseSSSinkConfig { | ||
| #[configurable(derived)] | ||
| pub(super) encoding: EncodingConfig, | ||
|
|
||
| /// The tag that specifies that a message belongs to a specific message group. | ||
| /// | ||
| /// Can be applied only to FIFO queues. | ||
| #[configurable(metadata(docs::examples = "vector"))] | ||
| #[configurable(metadata(docs::examples = "vector-%Y-%m-%d"))] | ||
| pub(super) message_group_id: Option<String>, | ||
|
|
||
| /// The message deduplication ID value to allow AWS to identify duplicate messages. | ||
| /// | ||
| /// This value is a template which should result in a unique string for each event. See the [AWS | ||
| /// documentation][deduplication_id_docs] for more about how AWS does message deduplication. | ||
| /// | ||
| /// [deduplication_id_docs]: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagededuplicationid-property.html | ||
| #[configurable(metadata(docs::examples = "{{ transaction_id }}"))] | ||
| pub(super) message_deduplication_id: Option<String>, | ||
|
|
||
| #[configurable(derived)] | ||
| #[serde(default)] | ||
| pub(super) request: TowerRequestConfig, | ||
|
|
||
| #[configurable(derived)] | ||
| pub(super) tls: Option<TlsConfig>, | ||
|
|
||
| /// The ARN of an [IAM role][iam_role] to assume at startup. | ||
| /// | ||
| /// [iam_role]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html | ||
| #[configurable(deprecated)] | ||
| #[configurable(metadata(docs::hidden))] | ||
| pub(super) assume_role: Option<String>, | ||
|
|
||
| #[configurable(derived)] | ||
| #[serde(default)] | ||
| pub(super) auth: AwsAuthentication, | ||
|
|
||
| #[configurable(derived)] | ||
| #[serde( | ||
| default, | ||
| deserialize_with = "crate::serde::bool_or_struct", | ||
| skip_serializing_if = "crate::serde::skip_serializing_if_default" | ||
| )] | ||
| pub(super) acknowledgements: AcknowledgementsConfig, | ||
| } | ||
|
|
||
| pub(super) fn message_group_id( | ||
| message_group_id: Option<String>, | ||
| fifo: bool, | ||
| ) -> crate::Result<Option<Template>> { | ||
| match (message_group_id.as_ref(), fifo) { | ||
| (Some(value), true) => Ok(Some( | ||
| Template::try_from(value.clone()).context(TopicTemplateSnafu)?, | ||
| )), | ||
| (Some(_), false) => Err(Box::new(BuildError::MessageGroupIdNotAllowed)), | ||
| (None, true) => Err(Box::new(BuildError::MessageGroupIdMissing)), | ||
| (None, false) => Ok(None), | ||
| } | ||
| } | ||
| pub(super) fn message_deduplication_id( | ||
| message_deduplication_id: Option<String>, | ||
| ) -> crate::Result<Option<Template>> { | ||
| Ok(message_deduplication_id | ||
| .clone() | ||
| .map(Template::try_from) | ||
| .transpose()?) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| mod client; | ||
| mod config; | ||
| mod request_builder; | ||
| mod retry; | ||
| mod service; | ||
| mod sink; | ||
|
|
||
| #[cfg(feature = "sinks-aws_sqs")] | ||
| mod sqs; | ||
|
|
||
| #[cfg(feature = "sinks-aws_sns")] | ||
| mod sns; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| use aws_sdk_sqs::types::SdkError; | ||
| use std::marker::PhantomData; | ||
|
|
||
| use super::service::SendMessageResponse; | ||
| use crate::{aws::is_retriable_error, sinks::util::retries::RetryLogic}; | ||
|
|
||
| #[derive(Debug)] | ||
| pub(super) struct SSRetryLogic<E> { | ||
| _phantom: PhantomData<fn() -> E>, | ||
| } | ||
|
|
||
| impl<E> SSRetryLogic<E> | ||
| where | ||
| E: std::fmt::Debug + std::fmt::Display + std::error::Error + Sync + Send + 'static, | ||
| { | ||
| pub(super) fn new() -> SSRetryLogic<E> { | ||
| Self { | ||
| _phantom: PhantomData, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<E> RetryLogic for SSRetryLogic<E> | ||
| where | ||
| E: std::fmt::Debug + std::fmt::Display + std::error::Error + Sync + Send + 'static, | ||
| { | ||
| type Error = SdkError<E>; | ||
| type Response = SendMessageResponse; | ||
|
|
||
| fn is_retriable_error(&self, error: &Self::Error) -> bool { | ||
| is_retriable_error(error) | ||
| } | ||
| } | ||
|
|
||
| impl<E> Clone for SSRetryLogic<E> | ||
| where | ||
| E: std::fmt::Debug + std::fmt::Display + std::error::Error + Sync + Send + 'static, | ||
| { | ||
| fn clone(&self) -> SSRetryLogic<E> { | ||
| SSRetryLogic { | ||
| _phantom: PhantomData, | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.