Skip to content

Commit

Permalink
Send client and rust version to server
Browse files Browse the repository at this point in the history
  • Loading branch information
tellet-q committed Dec 10, 2024
1 parent 29d394a commit 5b4144b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ reqwest = { version = "0.12.8", optional = true, default-features = false, featu
futures-util = { version = "0.3.31", optional = true }
derive_builder = { version = "0.20.2" }
thiserror = "1.0.64"
rustc_version = "0.4.1"

[dev-dependencies]
tonic-build = { version = "0.12.3", features = ["prost"] }
Expand Down
9 changes: 8 additions & 1 deletion src/channel_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::future::Future;
use std::sync::RwLock;
use std::time::Duration;

use rustc_version::version_meta;
use tonic::transport::{Channel, ClientTlsConfig, Uri};
use tonic::{Code, Status};

Expand Down Expand Up @@ -44,10 +45,16 @@ impl ChannelPool {
},
};

let rust_version = version_meta().unwrap().semver.to_string();
let rust_client_version = env!("CARGO_PKG_VERSION").to_string();
let version_info = format!("rust-client/{} rust/{}", rust_version, rust_client_version);

let endpoint = Channel::builder(self.uri.clone())
.timeout(self.grpc_timeout)
.connect_timeout(self.connection_timeout)
.keep_alive_while_idle(self.keep_alive_while_idle);
.keep_alive_while_idle(self.keep_alive_while_idle)
.user_agent(version_info)
.expect("Version info should be a valid header value");

let endpoint = if tls {
let tls_config = ClientTlsConfig::new().with_native_roots();
Expand Down

0 comments on commit 5b4144b

Please sign in to comment.