use crate::error::Result;
use crate::store::Store;
pub fn producer<'a>(hostname: &'a str, port: i32, queue: &'a str) -> ProducerBuilder<'a> {
ProducerBuilder::new(hostname, port, queue)
}
pub struct ProducerBuilder<'a> {
hostname: &'a str,
port: i32,
queue: &'a str,
}
impl<'a> ProducerBuilder<'a> {
pub fn new(hostname: &'a str, port: i32, queue: &'a str) -> Self {
Self {
hostname,
port,
queue,
}
}
pub async fn create<S: Store>(self, store: &S) -> Result<crate::workers::Producer> {
store
.producer(self.queue, self.hostname, self.port, store.config())
.await
}
}