Crates.io | sqs_listener |
lib.rs | sqs_listener |
version | 0.2.0 |
source | src |
created_at | 2021-08-03 19:08:27.351407 |
updated_at | 2021-08-03 21:31:57.140579 |
description | An easy to use listener, to listen for messages from SQS queues |
homepage | https://github.com/avencera/sqs_listener |
repository | https://github.com/avencera/sqs_listener |
max_upload_size | |
id | 431146 |
size | 68,308 |
Available on crates: crates.io/sqs_listener
Documentation available at: docs.rs/sqs_listener
sqs_listener = "0.1.0"
Simple example: /examples/simple.rs
use sqs_listener::{Region, SQSListener, SQSListenerClientBuilder};
#[tokio::main]
async fn main() -> eyre::Result<()> {
env_logger::init();
color_eyre::install()?;
let listener = SQSListener::new("".to_string(), |message| {
println!("Message received {:#?}", message)
});
let client = SQSListenerClientBuilder::new(Region::UsEast1)
.listener(listener)
.build()?;
let _ = client.start().await;
Ok(())
}
Example with creds: /examples/with_creds.rs
use std::env;
use sqs_listener::{
credential::StaticProvider, request::HttpClient, Region, SQSListener, SQSListenerClientBuilder,
};
#[tokio::main]
async fn main() -> eyre::Result<()> {
env_logger::init();
color_eyre::install()?;
let aws_access_key_id =
env::var("AWS_ACCESS_KEY_ID").expect("AWS_ACCESS_KEY_ID env variable needs to be present");
let aws_secret_access_key = env::var("AWS_SECRET_ACCESS_KEY")
.expect("AWS_SECRET_ACCESS_KEY env variable needs to be present");
let listener = SQSListener::new("".to_string(), |message| {
println!("Message received {:#?}", message)
});
let client = SQSListenerClientBuilder::new_with(
HttpClient::new().expect("failed to create request dispatcher"),
StaticProvider::new_minimal(aws_access_key_id, aws_secret_access_key),
Region::UsEast1,
)
.listener(listener)
.build()?;
let _ = client.start().await;
Ok(())
}