1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use lapin::{executor::Executor, ConnectionProperties}; use std::{future::Future, pin::Pin}; pub trait BastionExt { fn with_bastion(self) -> Self where Self: Sized, { self.with_bastion_executor() } fn with_bastion_executor(self) -> Self where Self: Sized; } impl BastionExt for ConnectionProperties { fn with_bastion_executor(self) -> Self { self.with_executor(BastionExecutor) } } #[derive(Debug)] struct BastionExecutor; impl Executor for BastionExecutor { fn spawn(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>) -> Result<(), lapin::Error> { bastion_executor::pool::spawn(f, Default::default()); Ok(()) } }