Skip to content

Commit

Permalink
Client module cleanup (#2)
Browse files Browse the repository at this point in the history
* Removed unused imports
* Removed Arc wrapping the RabbitmqBroker instance, not useful anymore.
  • Loading branch information
kureuil authored Feb 22, 2018
1 parent 1cd1783 commit 6795d39
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions batch/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
//! Batch client.
use std::fmt;
use std::iter::FromIterator;
use std::sync::{Arc, Mutex};
use std::result::Result as StdResult;

use futures::{future, Future, IntoFuture};
use futures::{future, Future};
use tokio_core::reactor::Handle;

use error::{Error, ErrorKind, Result};
use error::{Error, ErrorKind};
use job::Job;
use rabbitmq::{Exchange, ExchangeBuilder, RabbitmqBroker};
use task::Task;

/// A builder to ease the construction of `Client` instances.
#[derive(Debug)]
Expand Down Expand Up @@ -112,19 +108,15 @@ impl ClientBuilder {
self.exchanges,
vec![],
self.handle.unwrap(),
).and_then(|broker| {
Ok(Client {
broker: Arc::new(broker),
})
});
).and_then(|broker| Ok(Client { broker }));
Box::new(task)
}
}

/// The `Client` is responsible for sending tasks to the broker.
#[derive(Debug)]
pub struct Client {
broker: Arc<RabbitmqBroker>,
broker: RabbitmqBroker,
}

impl Client {
Expand All @@ -133,8 +125,7 @@ impl Client {
/// Once a job is sent to the message broker, it is transmitted to a Worker currently
/// receiving jobs from the same broker.
pub(crate) fn send(&self, job: &Job) -> Box<Future<Item = (), Error = Error>> {
let broker = Arc::clone(&self.broker);
let task = broker.send(job);
let task = self.broker.send(job);
Box::new(task)
}
}
Expand Down

0 comments on commit 6795d39

Please sign in to comment.