1use std::future::Future;
15use std::pin::Pin;
16use std::sync::Arc;
17use std::time::Duration;
18
19use super::{
20 BrokerMetadataApi, ConsumerApi, CreateProducerApi, Engine, MessageDecryptorApi,
21 MessageEncryptorApi, OperationDeadline, ProducerApi, ReceiveBatchFut, ReceiveOptFut,
22 SubscribeApi, TopicListChange, TransactionApi, WatchTopicListFut,
23};
24
25#[derive(Debug, Default, Clone, Copy)]
30pub struct TokioEngine;
31
32impl Engine for TokioEngine {
33 type ClientState = magnetar_runtime_tokio::Client;
34 type TaskHandle = tokio::task::JoinHandle<()>;
35 type Interval = tokio::time::Interval;
36
37 fn name() -> &'static str {
38 "tokio"
39 }
40
41 fn spawn<F>(fut: F) -> Self::TaskHandle
42 where
43 F: Future<Output = ()> + Send + 'static,
44 {
45 tokio::spawn(fut)
46 }
47
48 fn abort_task(handle: &mut Self::TaskHandle) {
49 handle.abort();
50 }
51
52 fn new_interval(period: Duration) -> Self::Interval {
53 tokio::time::interval(period)
56 }
57
58 fn interval_tick<'a>(
59 interval: &'a mut Self::Interval,
60 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> {
61 Box::pin(async move {
62 interval.tick().await;
63 })
64 }
65
66 fn random_subscription_suffix() -> String {
67 uuid::Uuid::new_v4().simple().to_string()
68 }
69}
70
71impl MessageEncryptorApi for TokioEngine {
76 type Encryptor = Arc<dyn magnetar_runtime_tokio::MessageEncryptor>;
77}
78
79impl MessageDecryptorApi for TokioEngine {
80 type Decryptor = Arc<dyn magnetar_runtime_tokio::MessageDecryptor>;
81}
82
83impl TransactionApi for magnetar_runtime_tokio::Client {
84 type Error = magnetar_runtime_tokio::ClientError;
85
86 fn new_txn(
87 &self,
88 timeout: Duration,
89 ) -> Pin<Box<dyn Future<Output = Result<magnetar_proto::TxnId, Self::Error>> + Send + '_>> {
90 Box::pin(magnetar_runtime_tokio::Client::new_txn(self, timeout))
91 }
92
93 fn add_partition_to_txn(
94 &self,
95 txn: magnetar_proto::TxnId,
96 topic: String,
97 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
98 Box::pin(magnetar_runtime_tokio::Client::add_partition_to_txn(
99 self, txn, topic,
100 ))
101 }
102
103 fn add_subscription_to_txn(
104 &self,
105 txn: magnetar_proto::TxnId,
106 topic: String,
107 subscription: String,
108 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
109 Box::pin(magnetar_runtime_tokio::Client::add_subscription_to_txn(
110 self,
111 txn,
112 topic,
113 subscription,
114 ))
115 }
116
117 fn end_txn(
118 &self,
119 txn: magnetar_proto::TxnId,
120 action: magnetar_proto::TxnAction,
121 ) -> Pin<Box<dyn Future<Output = Result<magnetar_proto::TxnState, Self::Error>> + Send + '_>>
122 {
123 Box::pin(magnetar_runtime_tokio::Client::end_txn(self, txn, action))
124 }
125}
126
127impl BrokerMetadataApi for magnetar_runtime_tokio::Client {
128 type Error = magnetar_runtime_tokio::ClientError;
129
130 fn partitioned_topic_metadata<'a>(
131 &'a self,
132 topic: &'a str,
133 ) -> Pin<Box<dyn Future<Output = Result<u32, Self::Error>> + Send + 'a>> {
134 Box::pin(magnetar_runtime_tokio::Client::partitioned_topic_metadata(
135 self, topic,
136 ))
137 }
138
139 fn new_metadata_operation_deadline(&self) -> OperationDeadline {
140 OperationDeadline::new(magnetar_runtime_tokio::Client::operation_timer(self))
141 }
142
143 fn partitioned_topic_metadata_with_deadline<'a>(
144 &'a self,
145 topic: &'a str,
146 deadline: &'a mut OperationDeadline,
147 ) -> Pin<Box<dyn Future<Output = Result<u32, Self::Error>> + Send + 'a>> {
148 let (timer, last_broker_error) = deadline.parts();
149 Box::pin(
150 magnetar_runtime_tokio::Client::partitioned_topic_metadata_with_operation_deadline(
151 self,
152 topic,
153 timer,
154 last_broker_error,
155 ),
156 )
157 }
158
159 fn watch_topic_list<'a>(
160 &'a self,
161 namespace: &'a str,
162 pattern: &'a str,
163 ) -> WatchTopicListFut<'a, Self> {
164 Box::pin(magnetar_runtime_tokio::Client::watch_topic_list(
165 self, namespace, pattern,
166 ))
167 }
168
169 fn watch_topic_list_with_deadline<'a>(
170 &'a self,
171 namespace: &'a str,
172 pattern: &'a str,
173 deadline: &'a mut OperationDeadline,
174 ) -> WatchTopicListFut<'a, Self> {
175 let (timer, last_broker_error) = deadline.parts();
176 Box::pin(
177 magnetar_runtime_tokio::Client::watch_topic_list_with_operation_deadline(
178 self,
179 namespace,
180 pattern,
181 timer,
182 last_broker_error,
183 ),
184 )
185 }
186
187 fn poll_topic_list_change(&self) -> Option<TopicListChange> {
188 magnetar_runtime_tokio::Client::poll_topic_list_change(self).map(|c| TopicListChange {
189 added: c.added,
190 removed: c.removed,
191 })
192 }
193}
194
195impl SubscribeApi for magnetar_runtime_tokio::Client {
196 type Consumer = magnetar_runtime_tokio::Consumer;
197 type Error = magnetar_runtime_tokio::ClientError;
198
199 fn subscribe(
200 &self,
201 req: magnetar_proto::SubscribeRequest,
202 ) -> Pin<Box<dyn Future<Output = Result<Self::Consumer, Self::Error>> + Send + '_>> {
203 Box::pin(magnetar_runtime_tokio::Client::subscribe(self, req))
204 }
205
206 fn new_subscribe_operation_deadline(&self) -> OperationDeadline {
207 OperationDeadline::new(magnetar_runtime_tokio::Client::operation_timer(self))
208 }
209
210 fn subscribe_with_deadline<'a>(
211 &'a self,
212 req: magnetar_proto::SubscribeRequest,
213 deadline: &'a mut OperationDeadline,
214 ) -> Pin<Box<dyn Future<Output = Result<Self::Consumer, Self::Error>> + Send + 'a>> {
215 let (timer, last_broker_error) = deadline.parts();
216 Box::pin(
217 magnetar_runtime_tokio::Client::subscribe_with_operation_deadline(
218 self,
219 req,
220 None,
221 timer,
222 last_broker_error,
223 ),
224 )
225 }
226}
227
228impl CreateProducerApi for magnetar_runtime_tokio::Client {
229 type Producer = magnetar_runtime_tokio::Producer;
230 type Error = magnetar_runtime_tokio::ClientError;
231
232 fn open_producer(
233 &self,
234 req: magnetar_proto::CreateProducerRequest,
235 ) -> Pin<Box<dyn Future<Output = Result<Self::Producer, Self::Error>> + Send + '_>> {
236 Box::pin(magnetar_runtime_tokio::Client::open_producer(self, req))
237 }
238
239 fn new_producer_operation_deadline(&self) -> OperationDeadline {
240 OperationDeadline::new(magnetar_runtime_tokio::Client::operation_timer(self))
241 }
242
243 fn open_producer_with_deadline<'a>(
244 &'a self,
245 req: magnetar_proto::CreateProducerRequest,
246 deadline: &'a mut OperationDeadline,
247 ) -> Pin<Box<dyn Future<Output = Result<Self::Producer, Self::Error>> + Send + 'a>> {
248 let (timer, last_broker_error) = deadline.parts();
249 Box::pin(
250 magnetar_runtime_tokio::Client::open_producer_with_operation_deadline(
251 self,
252 req,
253 None,
254 timer,
255 last_broker_error,
256 ),
257 )
258 }
259}
260
261impl ProducerApi for magnetar_runtime_tokio::Producer {
262 type Error = magnetar_runtime_tokio::ClientError;
263
264 fn send(
265 &self,
266 mut msg: crate::OutgoingMessage,
267 ) -> Pin<Box<dyn Future<Output = Result<magnetar_proto::MessageId, Self::Error>> + Send + '_>>
268 {
269 crate::inject_otel_context(&mut msg.properties);
270 Box::pin(magnetar_runtime_tokio::Producer::send(self, msg.into()))
271 }
272
273 fn flush(&self) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
274 Box::pin(magnetar_runtime_tokio::Producer::flush(self))
275 }
276
277 fn is_closed(&self) -> bool {
278 magnetar_runtime_tokio::Producer::is_closed(self)
279 }
280
281 fn is_connected(&self) -> bool {
282 magnetar_runtime_tokio::Producer::is_connected(self)
283 }
284
285 fn topic(&self) -> String {
286 magnetar_runtime_tokio::Producer::topic(self)
287 }
288
289 fn name(&self) -> String {
290 magnetar_runtime_tokio::Producer::name(self)
291 }
292
293 fn last_sequence_id(&self) -> i64 {
294 magnetar_runtime_tokio::Producer::last_sequence_id(self)
295 }
296
297 fn get_schema(
298 &self,
299 version: Option<bytes::Bytes>,
300 ) -> Pin<Box<dyn Future<Output = Result<magnetar_proto::pb::Schema, Self::Error>> + Send + '_>>
301 {
302 Box::pin(magnetar_runtime_tokio::Producer::get_schema(self, version))
303 }
304
305 fn stats(&self) -> magnetar_proto::producer::ProducerStats {
306 magnetar_runtime_tokio::Producer::stats(self)
307 }
308
309 fn send_latency_histogram(&self) -> Option<hdrhistogram::Histogram<u64>> {
310 magnetar_runtime_tokio::Producer::send_latency_histogram(self)
311 }
312
313 fn close_owned(self) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send>> {
314 Box::pin(magnetar_runtime_tokio::Producer::close(self))
315 }
316
317 fn last_disconnected_timestamp(&self) -> Option<std::time::SystemTime> {
318 magnetar_runtime_tokio::Producer::last_disconnected_timestamp(self)
319 }
320
321 fn compression(&self) -> magnetar_proto::types::CompressionKind {
322 magnetar_runtime_tokio::Producer::compression(self)
323 }
324
325 fn last_sequence_id_published(&self) -> i64 {
326 magnetar_runtime_tokio::Producer::last_sequence_id_published(self)
327 }
328
329 fn pending_count(&self) -> usize {
330 magnetar_runtime_tokio::Producer::pending_count(self)
331 }
332
333 fn batch_len(&self) -> usize {
334 magnetar_runtime_tokio::Producer::batch_len(self)
335 }
336
337 fn batch_bytes(&self) -> usize {
338 magnetar_runtime_tokio::Producer::batch_bytes(self)
339 }
340}
341
342#[cfg(feature = "scalable-topics")]
346impl super::ScalableTopicsApi for magnetar_runtime_tokio::Client {
347 type Error = magnetar_runtime_tokio::ClientError;
348
349 fn scalable_topic_lookup<'a>(
350 &'a self,
351 topic: &'a str,
352 ) -> Pin<Box<dyn Future<Output = Result<super::ScalableLookup, Self::Error>> + Send + 'a>> {
353 Box::pin(async move {
354 let l = magnetar_runtime_tokio::Client::scalable_topic_lookup(self, topic).await?;
355 Ok(super::ScalableLookup {
356 session_id: l.session_id,
357 resolved_topic_name: l.resolved_topic_name,
358 controller_broker_url: l.controller_broker_url,
359 segments: l.segments,
360 epoch: l.epoch,
361 })
362 })
363 }
364
365 fn broker_supports_scalable_topics(&self) -> bool {
366 magnetar_runtime_tokio::Client::broker_supports_scalable_topics(self)
367 }
368
369 fn close_scalable_topic_session(&self, session_id: u64) {
370 magnetar_runtime_tokio::Client::close_scalable_topic_session(self, session_id);
371 }
372
373 fn scalable_topic_subscribe<'a>(
374 &'a self,
375 topic: &'a str,
376 subscription: &'a str,
377 consumer_name: &'a str,
378 consumer_id: u64,
379 consumer_type: magnetar_proto::ScalableConsumerType,
380 ) -> Pin<
381 Box<
382 dyn Future<Output = Result<magnetar_proto::ConsumerAssignment, Self::Error>>
383 + Send
384 + 'a,
385 >,
386 > {
387 Box::pin(async move {
388 magnetar_runtime_tokio::Client::scalable_topic_subscribe(
389 self,
390 topic,
391 subscription,
392 consumer_name,
393 consumer_id,
394 consumer_type,
395 )
396 .await
397 })
398 }
399
400 fn watch_scalable_topics(
401 &self,
402 namespace: &str,
403 property_filters: Vec<(String, String)>,
404 ) -> Result<u64, Self::Error> {
405 magnetar_runtime_tokio::Client::watch_scalable_topics(self, namespace, property_filters)
406 }
407
408 fn close_scalable_topics_watch(&self, watch_id: u64) {
409 magnetar_runtime_tokio::Client::close_scalable_topics_watch(self, watch_id);
410 }
411
412 fn scalable_topics_snapshot(&self, watch_id: u64) -> Option<Vec<String>> {
413 magnetar_runtime_tokio::Client::scalable_topics_snapshot(self, watch_id)
414 }
415
416 fn broker_supports_tc_metadata_discovery(&self) -> bool {
417 magnetar_runtime_tokio::Client::broker_supports_tc_metadata_discovery(self)
418 }
419
420 fn watch_tc_assignments(&self) -> Result<u64, Self::Error> {
421 magnetar_runtime_tokio::Client::watch_tc_assignments(self)
422 }
423
424 fn close_tc_assignments_watch(&self, watch_id: u64) {
425 magnetar_runtime_tokio::Client::close_tc_assignments_watch(self, watch_id);
426 }
427
428 fn next_scalable_event(
429 &self,
430 ) -> Pin<Box<dyn Future<Output = Option<super::ScalableEvent>> + Send + '_>> {
431 Box::pin(async move {
432 magnetar_runtime_tokio::Client::next_scalable_event(self)
433 .await
434 .map(map_scalable_event)
435 })
436 }
437}
438
439#[cfg(feature = "scalable-topics")]
441fn map_scalable_event(ev: magnetar_runtime_tokio::ScalableEvent) -> super::ScalableEvent {
442 match ev {
443 magnetar_runtime_tokio::ScalableEvent::LookupResolved {
444 session_id,
445 resolved_topic_name,
446 controller_broker_url,
447 segments,
448 epoch,
449 } => super::ScalableEvent::LookupResolved {
450 session_id,
451 resolved_topic_name,
452 controller_broker_url,
453 segments,
454 epoch,
455 },
456 magnetar_runtime_tokio::ScalableEvent::DagUpdated { session_id, delta } => {
457 super::ScalableEvent::DagUpdated { session_id, delta }
458 }
459 magnetar_runtime_tokio::ScalableEvent::DagChangedDuringConsume { session_id, reason } => {
460 super::ScalableEvent::DagChangedDuringConsume { session_id, reason }
461 }
462 magnetar_runtime_tokio::ScalableEvent::DagWatchClosed { session_id, reason } => {
463 super::ScalableEvent::DagWatchClosed { session_id, reason }
464 }
465 magnetar_runtime_tokio::ScalableEvent::ConsumerAssigned {
466 consumer_id,
467 assignment,
468 } => super::ScalableEvent::ConsumerAssigned {
469 consumer_id,
470 assignment,
471 },
472 magnetar_runtime_tokio::ScalableEvent::AssignmentChanged { consumer_id, delta } => {
473 super::ScalableEvent::AssignmentChanged { consumer_id, delta }
474 }
475 magnetar_runtime_tokio::ScalableEvent::ConsumerRejected {
476 consumer_id,
477 reason,
478 } => super::ScalableEvent::ConsumerRejected {
479 consumer_id,
480 reason,
481 },
482 magnetar_runtime_tokio::ScalableEvent::TopicsChanged { watch_id, change } => {
483 super::ScalableEvent::TopicsChanged { watch_id, change }
484 }
485 magnetar_runtime_tokio::ScalableEvent::TopicsWatchClosed { watch_id, reason } => {
486 super::ScalableEvent::TopicsWatchClosed { watch_id, reason }
487 }
488 magnetar_runtime_tokio::ScalableEvent::TcAssignmentsChanged {
489 watch_id,
490 parallelism,
491 assignments,
492 } => super::ScalableEvent::TcAssignmentsChanged {
493 watch_id,
494 parallelism,
495 assignments,
496 },
497 magnetar_runtime_tokio::ScalableEvent::TcAssignmentsWatchClosed { watch_id, reason } => {
498 super::ScalableEvent::TcAssignmentsWatchClosed { watch_id, reason }
499 }
500 }
501}
502
503impl ConsumerApi for magnetar_runtime_tokio::Consumer {
504 type Error = magnetar_runtime_tokio::ClientError;
505 type Producer = magnetar_runtime_tokio::Producer;
506
507 fn receive(
508 &self,
509 ) -> Pin<
510 Box<dyn Future<Output = Result<magnetar_proto::IncomingMessage, Self::Error>> + Send + '_>,
511 > {
512 Box::pin(magnetar_runtime_tokio::Consumer::receive(self))
513 }
514
515 fn ack(
516 &self,
517 message_id: magnetar_proto::MessageId,
518 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
519 Box::pin(magnetar_runtime_tokio::Consumer::ack(self, message_id))
520 }
521
522 fn ack_cumulative(
523 &self,
524 message_id: magnetar_proto::MessageId,
525 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
526 Box::pin(magnetar_runtime_tokio::Consumer::ack_cumulative(
527 self, message_id,
528 ))
529 }
530
531 fn negative_ack(&self, message_id: magnetar_proto::MessageId) {
532 magnetar_runtime_tokio::Consumer::negative_ack(self, message_id);
533 }
534
535 fn last_message_id(
536 &self,
537 ) -> Pin<Box<dyn Future<Output = Result<magnetar_proto::MessageId, Self::Error>> + Send + '_>>
538 {
539 Box::pin(magnetar_runtime_tokio::Consumer::last_message_id(self))
540 }
541
542 fn has_message_after(
543 &self,
544 cursor: magnetar_proto::MessageId,
545 ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + '_>> {
546 Box::pin(magnetar_runtime_tokio::Consumer::has_message_after(
547 self, cursor,
548 ))
549 }
550
551 fn get_schema(
552 &self,
553 version: Option<bytes::Bytes>,
554 ) -> Pin<Box<dyn Future<Output = Result<magnetar_proto::pb::Schema, Self::Error>> + Send + '_>>
555 {
556 Box::pin(magnetar_runtime_tokio::Consumer::get_schema(self, version))
557 }
558
559 fn topic(&self) -> String {
560 magnetar_runtime_tokio::Consumer::topic(self)
561 }
562
563 fn subscription(&self) -> String {
564 magnetar_runtime_tokio::Consumer::subscription(self)
565 }
566
567 fn name(&self) -> String {
568 magnetar_runtime_tokio::Consumer::name(self)
569 }
570
571 fn is_closed(&self) -> bool {
572 magnetar_runtime_tokio::Consumer::is_closed(self)
573 }
574
575 fn is_connected(&self) -> bool {
576 magnetar_runtime_tokio::Consumer::is_connected(self)
577 }
578
579 fn stats(&self) -> magnetar_proto::consumer::ConsumerStats {
580 magnetar_runtime_tokio::Consumer::stats(self)
581 }
582
583 fn receive_latency_histogram(&self) -> Option<hdrhistogram::Histogram<u64>> {
584 magnetar_runtime_tokio::Consumer::receive_latency_histogram(self)
585 }
586
587 fn is_active(&self) -> Option<bool> {
588 magnetar_runtime_tokio::Consumer::is_active(self)
589 }
590
591 fn next_active_change(
592 &self,
593 ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + '_>> {
594 Box::pin(magnetar_runtime_tokio::Consumer::next_active_change(self))
595 }
596
597 fn last_disconnected_timestamp(&self) -> Option<std::time::SystemTime> {
598 magnetar_runtime_tokio::Consumer::last_disconnected_timestamp(self)
599 }
600
601 fn redeliver_unacked(&self) {
602 magnetar_runtime_tokio::Consumer::redeliver_unacked(self);
603 }
604
605 fn negative_ack_with_delay(
606 &self,
607 message_id: magnetar_proto::MessageId,
608 delay: std::time::Duration,
609 ) {
610 magnetar_runtime_tokio::Consumer::negative_ack_with_delay(self, message_id, delay);
611 }
612
613 fn unsubscribe(
614 &self,
615 force: bool,
616 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
617 Box::pin(magnetar_runtime_tokio::Consumer::unsubscribe(self, force))
618 }
619
620 fn seek_to_earliest(
621 &self,
622 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
623 Box::pin(magnetar_runtime_tokio::Consumer::seek_to_earliest(self))
624 }
625
626 fn seek_to_latest(&self) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
627 Box::pin(magnetar_runtime_tokio::Consumer::seek_to_latest(self))
628 }
629
630 fn seek_to_message(
631 &self,
632 message_id: magnetar_proto::MessageId,
633 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
634 Box::pin(magnetar_runtime_tokio::Consumer::seek_to_message(
635 self, message_id,
636 ))
637 }
638
639 fn seek_to_timestamp(
640 &self,
641 publish_time_ms: u64,
642 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
643 Box::pin(magnetar_runtime_tokio::Consumer::seek_to_timestamp(
644 self,
645 publish_time_ms,
646 ))
647 }
648
649 fn pause(&self) {
650 magnetar_runtime_tokio::Consumer::pause(self);
651 }
652
653 fn resume(&self) {
654 magnetar_runtime_tokio::Consumer::resume(self);
655 }
656
657 fn available_in_queue(&self) -> usize {
658 magnetar_runtime_tokio::Consumer::available_in_queue(self)
659 }
660
661 fn available_permits(&self) -> u32 {
662 magnetar_runtime_tokio::Consumer::available_permits(self)
663 }
664
665 fn has_received_any_message(&self) -> bool {
666 magnetar_runtime_tokio::Consumer::has_received_any_message(self)
667 }
668
669 fn has_reached_end_of_topic(&self) -> bool {
670 magnetar_runtime_tokio::Consumer::has_reached_end_of_topic(self)
671 }
672
673 fn is_paused(&self) -> bool {
674 magnetar_runtime_tokio::Consumer::is_paused(self)
675 }
676
677 fn is_inactive(&self) -> bool {
678 magnetar_runtime_tokio::Consumer::is_inactive(self)
679 }
680
681 fn drain_dead_letter(&self) -> Vec<magnetar_proto::IncomingMessage> {
682 magnetar_runtime_tokio::Consumer::drain_dead_letter(self)
683 }
684
685 fn receive_with_timeout(&self, timeout: Duration) -> ReceiveOptFut<'_, Self> {
686 Box::pin(magnetar_runtime_tokio::Consumer::receive_with_timeout(
687 self, timeout,
688 ))
689 }
690
691 fn receive_batch(&self, max_messages: usize, max_wait: Duration) -> ReceiveBatchFut<'_, Self> {
692 Box::pin(magnetar_runtime_tokio::Consumer::receive_batch(
693 self,
694 max_messages,
695 max_wait,
696 ))
697 }
698
699 fn receive_batch_with_bytes_cap(
700 &self,
701 max_messages: usize,
702 max_bytes: usize,
703 max_wait: Duration,
704 ) -> ReceiveBatchFut<'_, Self> {
705 Box::pin(
706 magnetar_runtime_tokio::Consumer::receive_batch_with_bytes_cap(
707 self,
708 max_messages,
709 max_bytes,
710 max_wait,
711 ),
712 )
713 }
714
715 fn republish_dead_letters<'a>(
716 &'a self,
717 dlq_producer: &'a Self::Producer,
718 ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'a>> {
719 Box::pin(magnetar_runtime_tokio::Consumer::republish_dead_letters(
720 self,
721 dlq_producer,
722 ))
723 }
724
725 fn reconsume_later<'a>(
726 &'a self,
727 retry_producer: &'a Self::Producer,
728 msg: magnetar_proto::IncomingMessage,
729 delay: Duration,
730 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>> {
731 Box::pin(magnetar_runtime_tokio::Consumer::reconsume_later(
732 self,
733 retry_producer,
734 msg,
735 delay,
736 ))
737 }
738
739 fn reconsume_later_with_properties<'a>(
740 &'a self,
741 retry_producer: &'a Self::Producer,
742 msg: magnetar_proto::IncomingMessage,
743 custom_properties: Vec<(String, String)>,
744 delay: Duration,
745 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>> {
746 Box::pin(
747 magnetar_runtime_tokio::Consumer::reconsume_later_with_properties(
748 self,
749 retry_producer,
750 msg,
751 custom_properties,
752 delay,
753 ),
754 )
755 }
756
757 fn close_owned(self) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send>> {
758 Box::pin(magnetar_runtime_tokio::Consumer::close(self))
759 }
760
761 fn ack_grouped(&self, message_id: magnetar_proto::MessageId) {
762 magnetar_runtime_tokio::Consumer::ack_grouped(self, message_id);
763 }
764
765 fn ack_grouped_cumulative(&self, message_id: magnetar_proto::MessageId) {
766 magnetar_runtime_tokio::Consumer::ack_grouped_cumulative(self, message_id);
767 }
768
769 fn ack_with_txn(
770 &self,
771 message_id: magnetar_proto::MessageId,
772 txn_id: magnetar_proto::TxnId,
773 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
774 Box::pin(magnetar_runtime_tokio::Consumer::ack_with_txn(
775 self, message_id, txn_id,
776 ))
777 }
778
779 fn ack_cumulative_with_txn(
780 &self,
781 message_id: magnetar_proto::MessageId,
782 txn_id: magnetar_proto::TxnId,
783 ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + '_>> {
784 Box::pin(magnetar_runtime_tokio::Consumer::ack_cumulative_with_txn(
785 self, message_id, txn_id,
786 ))
787 }
788}