rustack_sqs_http/
dispatch.rs1use std::{future::Future, pin::Pin};
4
5use bytes::Bytes;
6use rustack_sqs_model::{error::SqsError, operations::SqsOperation};
7
8use crate::body::SqsResponseBody;
9
10pub trait SqsHandler: Send + Sync + 'static {
16 fn handle_operation(
18 &self,
19 op: SqsOperation,
20 body: Bytes,
21 ) -> Pin<Box<dyn Future<Output = Result<http::Response<SqsResponseBody>, SqsError>> + Send>>;
22}
23
24pub async fn dispatch_operation<H: SqsHandler>(
26 handler: &H,
27 op: SqsOperation,
28 body: Bytes,
29) -> Result<http::Response<SqsResponseBody>, SqsError> {
30 tracing::debug!(operation = %op, "dispatching SQS operation");
31 handler.handle_operation(op, body).await
32}