implement ofborg version property for lapin

This commit is contained in:
Daiderd Jordan 2020-04-29 21:37:01 +02:00
parent eae94fe00a
commit 737871ea84
No known key found for this signature in database
GPG key ID: D02435D05B810C96

View file

@ -3,19 +3,25 @@ use std::pin::Pin;
use crate::config::RabbitMQConfig;
use crate::easyamqp::*;
use crate::notifyworker::{NotificationReceiver, SimpleNotifyWorker};
use crate::ofborg;
use crate::worker::{Action, SimpleWorker};
use async_std::future::Future;
use async_std::stream::StreamExt;
use async_std::task;
use lapin::{
message::Delivery, options::*, types::FieldTable, BasicProperties, Channel, CloseOnDrop,
types::AMQPValue, message::Delivery, options::*, types::FieldTable, BasicProperties, Channel, CloseOnDrop,
Connection, ConnectionProperties, ExchangeKind,
};
pub fn from_config(cfg: &RabbitMQConfig) -> Result<CloseOnDrop<Connection>, lapin::Error> {
let opts = ConnectionProperties::default();
// TODO version
let mut props = FieldTable::default();
props.insert(
"ofborg_version".into(),
AMQPValue::LongString(ofborg::VERSION.into()),
);
let mut opts = ConnectionProperties::default();
opts.client_properties = props;
task::block_on(Connection::connect(&cfg.as_uri(), opts))
}