Skip to content

Commit b21981d

Browse files
committed
Add client properties
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
1 parent f2aca24 commit b21981d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/client/mod.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ pub struct Client {
200200
tune_notifier: Arc<Notify>,
201201
publish_sequence: Arc<AtomicU64>,
202202
filtering_supported: bool,
203+
client_properties: HashMap<String, String>,
203204
}
204205

205206
impl Client {
@@ -227,8 +228,29 @@ impl Client {
227228
tune_notifier: Arc::new(Notify::new()),
228229
publish_sequence: Arc::new(AtomicU64::new(1)),
229230
filtering_supported: false,
231+
client_properties: HashMap::new(),
230232
};
231233

234+
client
235+
.client_properties
236+
.insert(String::from("product"), String::from("RabbitMQ"));
237+
client
238+
.client_properties
239+
.insert(String::from("platform"), String::from("Rust"));
240+
client.client_properties.insert(
241+
String::from("copyright"),
242+
String::from("Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries."));
243+
client.client_properties.insert(
244+
String::from("information"),
245+
String::from(
246+
"Licensed under the Apache 2.0 and MPL 2.0 licenses. See https://www.rabbitmq.com/",
247+
),
248+
);
249+
client.client_properties.insert(
250+
String::from("connection_name"),
251+
client.opts.client_provided_name.clone(),
252+
);
253+
232254
client.initialize(receiver).await?;
233255

234256
let command_versions = client.exchange_command_versions().await?;
@@ -676,7 +698,7 @@ impl Client {
676698

677699
async fn peer_properties(&self) -> Result<HashMap<String, String>, ClientError> {
678700
self.send_and_receive::<PeerPropertiesResponse, _, _>(|correlation_id| {
679-
PeerPropertiesCommand::new(correlation_id, HashMap::new())
701+
PeerPropertiesCommand::new(correlation_id, self.client_properties.clone())
680702
})
681703
.await
682704
.map(|peer_properties| peer_properties.server_properties)

src/client/options.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct ClientOptions {
1515
pub(crate) load_balancer_mode: bool,
1616
pub(crate) tls: TlsConfiguration,
1717
pub(crate) collector: Arc<dyn MetricsCollector>,
18+
pub(crate) client_provided_name: String,
1819
}
1920

2021
impl Debug for ClientOptions {
@@ -27,6 +28,7 @@ impl Debug for ClientOptions {
2728
.field("v_host", &self.v_host)
2829
.field("heartbeat", &self.heartbeat)
2930
.field("max_frame_size", &self.max_frame_size)
31+
.field("client_provided_name", &self.client_provided_name)
3032
.finish()
3133
}
3234
}
@@ -49,6 +51,7 @@ impl Default for ClientOptions {
4951
client_certificates_path: String::from(""),
5052
client_keys_path: String::from(""),
5153
},
54+
client_provided_name: String::from("rust-stream"),
5255
}
5356
}
5457
}

0 commit comments

Comments
 (0)