Skip to content

Commit fe35aae

Browse files
authored
refactor: replace BuildInfoRef with semver::Version in RpcClientConf (databendlabs#19281)
Change `RpcClientConf::version` field type from `BuildInfoRef` to `semver::Version`. Only `.semantic` was ever accessed, so the full `BuildInfo` struct was unnecessary. Changes: - Change `RpcClientConf::version` from `BuildInfoRef` to `Version` - Update `RpcClientConf::empty()` to accept `Version` - Update `to_meta_grpc_client_conf()` to accept `semver::Version` - Simplify access patterns: `.version.semantic.clone()` → `.version.clone()` - Update all callers to pass `.semver()` instead of full `BuildInfoRef`
1 parent fcca667 commit fe35aae

28 files changed

Lines changed: 45 additions & 39 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bendsave/src/storage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub async fn verify_query_license(cfg: &InnerConfig, version: BuildInfoRef) -> R
109109
RealLicenseManager::init(cfg.query.tenant_id.tenant_name().to_string())?;
110110
SessionManager::init(cfg)?;
111111
UserApiProvider::init(
112-
cfg.meta.to_meta_grpc_client_conf(version),
112+
cfg.meta.to_meta_grpc_client_conf(version.semver()),
113113
&CacheConfig::default(),
114114
BuiltIn::default(),
115115
&cfg.query.tenant_id,
@@ -146,7 +146,7 @@ pub async fn load_databend_meta() -> Result<(
146146
impl TryStream<Ok = Bytes, Error = anyhow::Error>,
147147
)> {
148148
let cfg = GlobalConfig::instance();
149-
let grpc_client_conf = cfg.meta.to_meta_grpc_client_conf(&BUILD_INFO);
149+
let grpc_client_conf = cfg.meta.to_meta_grpc_client_conf(BUILD_INFO.semver());
150150
debug!("connect meta services on {:?}", grpc_client_conf.endpoints);
151151

152152
let meta_client = MetaGrpcClient::try_new(&grpc_client_conf)?;

src/common/grpc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ hyper = { workspace = true }
1616
hyper-util = { workspace = true }
1717
jwt-simple = { workspace = true }
1818
log = { workspace = true }
19+
semver = { workspace = true }
1920
serde = { workspace = true }
2021
thiserror = { workspace = true }
2122
tokio = { workspace = true }

src/common/grpc/src/client_conf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use std::time::Duration;
1616

17-
use databend_common_base::base::BuildInfoRef;
17+
use semver::Version;
1818

1919
#[derive(Clone, Debug, Default)]
2020
pub struct RpcClientTlsConfig {
@@ -32,7 +32,7 @@ impl RpcClientTlsConfig {
3232
pub struct RpcClientConf {
3333
pub embedded_dir: Option<String>,
3434
pub endpoints: Vec<String>,
35-
pub version: BuildInfoRef,
35+
pub version: Version,
3636
pub username: String,
3737
pub password: String,
3838
pub tls_conf: Option<RpcClientTlsConfig>,
@@ -61,7 +61,7 @@ impl RpcClientConf {
6161
self.endpoints.clone()
6262
}
6363

64-
pub fn empty(version: BuildInfoRef) -> Self {
64+
pub fn empty(version: Version) -> Self {
6565
Self {
6666
embedded_dir: None,
6767
endpoints: vec![],

src/meta/binaries/meta/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ async fn run_kvapi_command(conf: &Config, op: &str) {
231231
endpoints: vec![conf.grpc_api_address.clone()],
232232
username: conf.username.clone(),
233233
password: conf.password.clone(),
234-
..RpcClientConf::empty(&BUILD_INFO)
234+
..RpcClientConf::empty(BUILD_INFO.semver())
235235
};
236236
let client = match MetaStoreProvider::new(rpc_conf).create_meta_store().await {
237237
Ok(s) => Arc::new(s),

src/meta/client/src/grpc_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl MetaGrpcClient {
151151
pub fn try_new(conf: &RpcClientConf) -> Result<Arc<ClientHandle>, CreationError> {
152152
Self::try_create(
153153
conf.get_endpoints(),
154-
conf.version.semantic.clone(),
154+
conf.version.clone(),
155155
&conf.username,
156156
&conf.password,
157157
conf.timeout,

src/meta/store/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl MetaStoreProvider {
198198
LocalMetaService::new_with_fixed_dir(
199199
self.rpc_conf.embedded_dir.clone(),
200200
"MetaStoreProvider-created",
201-
self.rpc_conf.version.semantic.clone(),
201+
self.rpc_conf.version.clone(),
202202
)
203203
.await
204204
.unwrap(),

src/query/catalog/src/catalog/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl CatalogManager {
9191
) -> Result<Arc<CatalogManager>> {
9292
let meta = {
9393
let provider = Arc::new(MetaStoreProvider::new(
94-
conf.meta.to_meta_grpc_client_conf(version),
94+
conf.meta.to_meta_grpc_client_conf(version.semver()),
9595
));
9696

9797
provider.create_meta_store().await.map_err(|e| {

src/query/config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ databend-common-meta-app = { workspace = true }
2626
databend-common-storage = { workspace = true }
2727
databend-common-tracing = { workspace = true }
2828
log = { workspace = true }
29+
semver = { workspace = true }
2930
serde = { workspace = true }
3031
serde_ignored = { workspace = true }
3132
serde_with = { workspace = true }

src/query/config/src/inner.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::str::FromStr;
2222
use std::time::Duration;
2323

2424
use databend_base::uniq_id::GlobalUniq;
25-
use databend_common_base::base::BuildInfoRef;
2625
use databend_common_base::base::OrderedFloat;
2726
use databend_common_base::base::mask_string;
2827
use databend_common_exception::ErrorCode;
@@ -445,7 +444,7 @@ impl MetaConfig {
445444
}
446445
}
447446

448-
pub fn to_meta_grpc_client_conf(&self, version: BuildInfoRef) -> RpcClientConf {
447+
pub fn to_meta_grpc_client_conf(&self, version: semver::Version) -> RpcClientConf {
449448
let embedded_dir = if self.embedded_dir.is_empty() {
450449
None
451450
} else {

0 commit comments

Comments
 (0)