chore: improve opendal layers (#1295)

* chore: improve opendal layers

* chore: log level
This commit is contained in:
dennis zhuang
2023-03-31 17:48:11 +08:00
committed by GitHub
parent eb77f9aafd
commit 972f64c3d7
4 changed files with 17 additions and 4 deletions

1
Cargo.lock generated
View File

@@ -2402,6 +2402,7 @@ dependencies = [
"futures-util",
"humantime-serde",
"hyper",
"log",
"log-store",
"meta-client",
"meta-srv",

View File

@@ -94,7 +94,7 @@ impl<E: ErrorExt + 'static> RepeatedTask<E> {
*self.task_handle.lock().await = Some(handle);
self.started.store(true, Ordering::Relaxed);
logging::info!(
logging::debug!(
"Repeated task {} started with interval: {:?}",
self.task_fn.name(),
self.interval
@@ -127,7 +127,7 @@ impl<E: ErrorExt + 'static> RepeatedTask<E> {
token.cancel();
handle.await.context(WaitGcTaskStopSnafu { name })?;
logging::info!("Repeated task {} stopped", name);
logging::debug!("Repeated task {} stopped", name);
Ok(())
}
}

View File

@@ -38,6 +38,7 @@ futures = "0.3"
futures-util.workspace = true
hyper = { version = "0.14", features = ["full"] }
humantime-serde = "1.1"
log = "0.4"
log-store = { path = "../log-store" }
meta-client = { path = "../meta-client" }
meta-srv = { path = "../meta-srv", features = ["mock"] }

View File

@@ -315,11 +315,22 @@ pub(crate) async fn new_object_store(store_config: &ObjectStoreConfig) -> Result
ObjectStoreConfig::Oss { .. } => new_oss_object_store(store_config).await,
};
// Don't enable retry layer when using local file backend.
let object_store = if !matches!(store_config, ObjectStoreConfig::File(..)) {
object_store.map(|object_store| object_store.layer(RetryLayer::new().with_jitter()))
} else {
object_store
};
object_store.map(|object_store| {
object_store
.layer(RetryLayer::new().with_jitter())
.layer(MetricsLayer)
.layer(LoggingLayer::default())
.layer(
LoggingLayer::default()
// Print the expected error only in DEBUG level.
// See https://docs.rs/opendal/latest/opendal/layers/struct.LoggingLayer.html#method.with_error_level
.with_error_level(Some(log::Level::Debug)),
)
.layer(TracingLayer)
})
}