Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions ofborg/src/easylapin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ pub fn from_config(cfg: &RabbitMQConfig) -> Result<Connection, lapin::Error> {
"ofborg_version".into(),
AMQPValue::LongString(ofborg::VERSION.into()),
);
let mut opts = ConnectionProperties::default();
opts.client_properties = props;
let opts = ConnectionProperties {
client_properties: props,
..Default::default()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat, I didn't know this is also a thing with defaults.

};
task::block_on(Connection::connect(&cfg.as_uri(), opts))
}

impl ChannelExt for Channel {
type Error = lapin::Error;

fn declare_exchange(&mut self, config: ExchangeConfig) -> Result<(), Self::Error> {
let mut opts = ExchangeDeclareOptions::default();
opts.passive = config.passive;
opts.durable = config.durable;
opts.auto_delete = config.auto_delete;
opts.internal = config.internal;
opts.nowait = config.no_wait;
let opts = ExchangeDeclareOptions {
passive: config.passive,
durable: config.durable,
auto_delete: config.auto_delete,
internal: config.internal,
nowait: config.no_wait,
};

let kind = match config.exchange_type {
ExchangeType::Topic => ExchangeKind::Topic,
Expand All @@ -53,20 +56,22 @@ impl ChannelExt for Channel {
}

fn declare_queue(&mut self, config: QueueConfig) -> Result<(), Self::Error> {
let mut opts = QueueDeclareOptions::default();
opts.passive = config.passive;
opts.durable = config.durable;
opts.exclusive = config.exclusive;
opts.auto_delete = config.auto_delete;
opts.nowait = config.no_wait;
let opts = QueueDeclareOptions {
passive: config.passive,
durable: config.durable,
exclusive: config.exclusive,
auto_delete: config.auto_delete,
nowait: config.no_wait,
};

task::block_on(self.queue_declare(&config.queue, opts, FieldTable::default()))?;
Ok(())
}

fn bind_queue(&mut self, config: BindQueueConfig) -> Result<(), Self::Error> {
let mut opts = QueueBindOptions::default();
opts.nowait = config.no_wait;
let opts = QueueBindOptions {
nowait: config.no_wait,
};

task::block_on(self.queue_bind(
&config.queue,
Expand Down Expand Up @@ -202,8 +207,10 @@ async fn action_deliver(
}
Action::NackRequeue => {
debug!(?deliver.delivery_tag, "action nack requeue");
let mut opts = BasicNackOptions::default();
opts.requeue = true;
let opts = BasicNackOptions {
requeue: true,
..Default::default()
};
chan.basic_nack(deliver.delivery_tag, opts).await
}
Action::NackDump => {
Expand Down