pub struct RequestResponseService { /* private fields */ }Expand description
Service for request-response pattern using PostgreSQL. Uses queue for requests and LISTEN/NOTIFY for responses.
Implementations§
Source§impl RequestResponseService
impl RequestResponseService
pub fn new(pool: PgPool, queue: QueueRepository) -> Self
Sourcepub async fn push_and_wait<Req, Resp>(
&self,
queue: &QueueName,
request: &Req,
timeout_duration: Duration,
) -> Result<Resp>where
Req: Serialize,
Resp: DeserializeOwned,
pub async fn push_and_wait<Req, Resp>(
&self,
queue: &QueueName,
request: &Req,
timeout_duration: Duration,
) -> Result<Resp>where
Req: Serialize,
Resp: DeserializeOwned,
Push a request to a queue and wait for a response.
Sets up a LISTEN channel before pushing to avoid race conditions.
The processor must call store_response() with the matching request_id.
Sourcepub async fn store_response<T: Serialize>(
&self,
request_id: &Uuid,
response: &T,
) -> Result<()>
pub async fn store_response<T: Serialize>( &self, request_id: &Uuid, response: &T, ) -> Result<()>
Store a response for a request (called by the processor)
Sourcepub async fn cleanup_old_responses(&self, older_than: Duration) -> Result<u64>
pub async fn cleanup_old_responses(&self, older_than: Duration) -> Result<u64>
Clean up old responses (housekeeping)
Trait Implementations§
Source§impl Clone for RequestResponseService
impl Clone for RequestResponseService
Source§fn clone(&self) -> RequestResponseService
fn clone(&self) -> RequestResponseService
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RequestResponseService
impl !RefUnwindSafe for RequestResponseService
impl Send for RequestResponseService
impl Sync for RequestResponseService
impl Unpin for RequestResponseService
impl UnsafeUnpin for RequestResponseService
impl !UnwindSafe for RequestResponseService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more