Skip to content

Commit 1862517

Browse files
committed
Add transaction context creation from Redis pipeline
- Introduced `transaction_context_from_pipeline` method to allow atomic job queuing within an existing Redis transaction. - This enhancement improves the flexibility of transaction handling in the queue implementation.
1 parent 0925946 commit 1862517

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

twmq/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ impl<H: DurableExecution> Queue<H> {
161161
}
162162
}
163163

164+
/// Create a TransactionContext from an existing Redis pipeline
165+
/// This allows queueing jobs atomically within an existing transaction
166+
pub fn transaction_context_from_pipeline<'a>(
167+
&self,
168+
pipeline: &'a mut redis::Pipeline,
169+
) -> hooks::TransactionContext<'a> {
170+
hooks::TransactionContext::new(pipeline, self.name.clone())
171+
}
172+
164173
// Get queue name
165174
pub fn name(&self) -> &str {
166175
&self.name

0 commit comments

Comments
 (0)