-
Notifications
You must be signed in to change notification settings - Fork 124
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: add sqs source #2355
base: main
Are you sure you want to change the base?
feat: add sqs source #2355
Conversation
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Shrivardhan Rao <[email protected]>
use std::collections::HashMap; | ||
use std::time::Duration; | ||
use tokio::sync::{mpsc, oneshot}; | ||
use tokio::time::Instant; | ||
|
||
use aws_config::{meta::region::RegionProviderChain, BehaviorVersion}; | ||
use aws_sdk_sqs::config::Region; | ||
use aws_sdk_sqs::types::{MessageSystemAttributeName, QueueAttributeName}; | ||
use aws_sdk_sqs::{Client}; | ||
use bytes::Bytes; | ||
use chrono::{DateTime, TimeZone, Utc}; | ||
|
||
use crate::{Error, Result}; |
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.
Group imports in std-external-crate
order https://rust-lang.github.io/rustfmt/?version=master&search=#StdExternalCrate%5C%3A
We try to follow this for new changes.
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.
I have added --config group_imports=StdExternalCrate
to my Rust Rover rustfmt arguments. Should we add a rustfmt.toml?
please resolve conflicts |
Signed-off-by: Shrivardhan Rao <[email protected]>
Signed-off-by: Shrivardhan Rao <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2355 +/- ##
==========================================
+ Coverage 69.84% 69.87% +0.03%
==========================================
Files 361 364 +3
Lines 49935 50823 +888
==========================================
+ Hits 34878 35515 +637
- Misses 13979 14229 +250
- Partials 1078 1079 +1 ☔ View full report in Codecov by Sentry. |
rust/extns/numaflow-sqs/Cargo.toml
Outdated
tonic = "0.12.3" | ||
prost = "0.11.9" | ||
thiserror = "1.0.69" | ||
http = "1.2.0" |
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.
do we need http?
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.
@cosmic-chichu You can use cargo-udeps
to identify crates that are not used.
# Install
cargo install cargo-udeps
# Go to the crates directory and run it. It needs nightly compiler
cd rust/extns/numaflow-sqs
cargo +nightly udeps --all-targets
chrono = "0.4.38" | ||
tonic = "0.12.3" | ||
prost = "0.11.9" | ||
thiserror = "1.0.69" |
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.
workspace
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error("Failed with SQS error - {0}")] | ||
SQS(aws_sdk_sqs::Error), |
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.
to handle this error in the core, we will have to import aws_sdk_sqs, right? so convert this to numaflow error.
@cosmic-chichu Run cd rust/extns/numaflow-sqs
cargo clippy --tests --all-features --no-deps |
pub struct SQSSourceConfig { | ||
pub region: String, | ||
pub queue_name: String, |
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.
we might have to enhance it with more sqs
source related configs like visibility timeout, poll timeout etc.
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.
Lets add support for all the configurations that is supported by SQS Client.
/// Used to initialize the SQS client with region and queue settings. | ||
/// Implements serde::Deserialize to support loading from configuration files. |
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.
we might need to support different ways to authenticate (example role-based)
respond_to: tx, | ||
queue_name: self.queue_name.clone(), | ||
count: self.batch_size as i32, | ||
timeout_at: Instant::now() + self.timeout, |
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.
timeout_at: Instant::now() + self.timeout, | |
timeout_at: start + self.timeout, |
timeout_at, | ||
} => { | ||
let messages = self.get_messages(queue_name, count, timeout_at).await; | ||
let _ = respond_to.send(messages); |
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.
use expect?
} | ||
_ => { | ||
tracing::error!("Unsupported attribute name"); | ||
let _ = respond_to |
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.
use expect?
let status = self.delete_messages(queue_name, offsets).await; | ||
let _ = respond_to.send(status); | ||
} | ||
SQSActorMessage::GetQueueAttributes { |
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.
Can we avoid this actor message and move this functionality inside pending?
GetQueueAttributes { | ||
respond_to: oneshot::Sender<Result<Option<usize>>>, | ||
queue_name: String, | ||
attribute_name: QueueAttributeName, | ||
}, |
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.
make this pending?
} | ||
|
||
/// Retrieves messages from SQS with timeout and batching. | ||
/// |
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.
make queue static to avoid dynamic queue url creation and to avoid caching?
Signed-off-by: Shrivardhan Rao <[email protected]>
Signed-off-by: Shrivardhan Rao <[email protected]>
Signed-off-by: Shrivardhan Rao <[email protected]>
event_time: message.event_time, | ||
watermark: None, |
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.
why not set Watermark
based of SentTimestamp
in the Attributes
resolves #2367