-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : alerts module init * feat : added alerts in jobs/mod.rs * feat : updated messages * feat : updated tests with alerts module mock * changelog : update * feat : added additional alerts * feat : added test for alerts and added logs at queue level * refactor : removed redundant alerts * feat : updated workflow * feat : resolved comments * feat : added all alerts for queues * feat : updated code * remove queue url const * feat : tests and lint fixes --------- Co-authored-by: apoorvsadana <[email protected]>
- Loading branch information
1 parent
77bf9c6
commit f84ba41
Showing
16 changed files
with
240 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,27 @@ | ||
use crate::alerts::Alerts; | ||
use async_trait::async_trait; | ||
use aws_sdk_sns::config::Region; | ||
use aws_sdk_sns::Client; | ||
use utils::env_utils::get_env_var_or_panic; | ||
|
||
pub struct AWSSNS { | ||
client: Client, | ||
} | ||
|
||
impl AWSSNS { | ||
/// To create a new SNS client | ||
pub async fn new() -> Self { | ||
let sns_region = get_env_var_or_panic("AWS_SNS_REGION"); | ||
let config = aws_config::from_env().region(Region::new(sns_region)).load().await; | ||
AWSSNS { client: Client::new(&config) } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Alerts for AWSSNS { | ||
async fn send_alert_message(&self, message_body: String) -> color_eyre::Result<()> { | ||
let topic_arn = get_env_var_or_panic("AWS_SNS_ARN"); | ||
self.client.publish().topic_arn(topic_arn).message(message_body).send().await?; | ||
Ok(()) | ||
} | ||
} |
This file contains 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,11 @@ | ||
use async_trait::async_trait; | ||
use mockall::automock; | ||
|
||
pub mod aws_sns; | ||
|
||
#[automock] | ||
#[async_trait] | ||
pub trait Alerts: Send + Sync { | ||
/// To send an alert message to our alert service | ||
async fn send_alert_message(&self, message_body: String) -> color_eyre::Result<()>; | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.