Skip to content

Commit

Permalink
add helper to set connection_name
Browse files Browse the repository at this point in the history
Fixes amqp-rs#319

Signed-off-by: Marc-Antoine Perennou <[email protected]>
  • Loading branch information
Keruspe committed Jan 18, 2021
1 parent 5785da0 commit 12ad229
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() -> Result<()> {
async_global_executor::block_on(async {
let conn = Connection::connect(
&addr,
ConnectionProperties::default().with_default_executor(8),
ConnectionProperties::default().with_default_executor(8).with_connection_name("pubsub-example".into()),
)
.await?;

Expand Down
7 changes: 6 additions & 1 deletion src/connection_properties.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
executor::{DefaultExecutor, Executor},
reactor::ReactorBuilder,
types::FieldTable,
types::{AMQPValue, FieldTable, LongString},
};
use std::sync::Arc;

Expand All @@ -25,6 +25,11 @@ impl Default for ConnectionProperties {
}

impl ConnectionProperties {
pub fn with_connection_name(mut self, connection_name: LongString) -> Self {
self.client_properties.insert("connection_name".into(), AMQPValue::LongString(connection_name));
self
}

pub fn with_executor<E: Executor + 'static>(mut self, executor: E) -> Self {
self.executor = Some(Arc::new(executor));
self
Expand Down

0 comments on commit 12ad229

Please sign in to comment.