Remove expect
s when constructing Clickhouse client (#8697)
This PR removes the `expect`s when constructing the Clickhouse client while still retaining the less-noisy behavior from before. Release Notes: - N/A
This commit is contained in:
parent
cfe90c37fc
commit
486f0ae454
1 changed files with 30 additions and 27 deletions
|
@ -176,7 +176,10 @@ impl AppState {
|
||||||
db: Arc::new(db),
|
db: Arc::new(db),
|
||||||
live_kit_client,
|
live_kit_client,
|
||||||
blob_store_client: build_blob_store_client(&config).await.log_err(),
|
blob_store_client: build_blob_store_client(&config).await.log_err(),
|
||||||
clickhouse_client: build_clickhouse_client(&config),
|
clickhouse_client: config
|
||||||
|
.clickhouse_url
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|_| build_clickhouse_client(&config).log_err()),
|
||||||
config,
|
config,
|
||||||
};
|
};
|
||||||
Ok(Arc::new(this))
|
Ok(Arc::new(this))
|
||||||
|
@ -218,30 +221,30 @@ async fn build_blob_store_client(config: &Config) -> anyhow::Result<aws_sdk_s3::
|
||||||
Ok(aws_sdk_s3::Client::new(&s3_config))
|
Ok(aws_sdk_s3::Client::new(&s3_config))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_clickhouse_client(config: &Config) -> Option<clickhouse::Client> {
|
fn build_clickhouse_client(config: &Config) -> anyhow::Result<clickhouse::Client> {
|
||||||
let Some(url) = config.clickhouse_url.as_ref() else {
|
Ok(clickhouse::Client::default()
|
||||||
return None;
|
.with_url(
|
||||||
};
|
config
|
||||||
Some(
|
.clickhouse_url
|
||||||
clickhouse::Client::default()
|
.as_ref()
|
||||||
.with_url(url)
|
.ok_or_else(|| anyhow!("missing clickhouse_url"))?,
|
||||||
.with_user(
|
)
|
||||||
config
|
.with_user(
|
||||||
.clickhouse_user
|
config
|
||||||
.as_ref()
|
.clickhouse_user
|
||||||
.expect("missing clickhouse_user"),
|
.as_ref()
|
||||||
)
|
.ok_or_else(|| anyhow!("missing clickhouse_user"))?,
|
||||||
.with_password(
|
)
|
||||||
config
|
.with_password(
|
||||||
.clickhouse_password
|
config
|
||||||
.as_ref()
|
.clickhouse_password
|
||||||
.expect("missing clickhouse_password"),
|
.as_ref()
|
||||||
)
|
.ok_or_else(|| anyhow!("missing clickhouse_password"))?,
|
||||||
.with_database(
|
)
|
||||||
config
|
.with_database(
|
||||||
.clickhouse_database
|
config
|
||||||
.as_ref()
|
.clickhouse_database
|
||||||
.expect("missing clickhouse_database"),
|
.as_ref()
|
||||||
),
|
.ok_or_else(|| anyhow!("missing clickhouse_database"))?,
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue