refactor: add object store resolver for standalone crates (#3437)

This commit is contained in:
安正超
2026-06-14 18:02:39 +08:00
committed by GitHub
parent 59f99a30e2
commit 84f7027e90
12 changed files with 105 additions and 67 deletions
+15
View File
@@ -171,6 +171,21 @@ pub fn new_object_layer_fn() -> Option<Arc<ECStore>> {
GLOBAL_OBJECT_API.get().cloned()
}
pub type ObjectStoreResolver = dyn Fn() -> Option<Arc<ECStore>> + Send + Sync + 'static;
static GLOBAL_OBJECT_STORE_RESOLVER: OnceLock<Arc<ObjectStoreResolver>> = OnceLock::new();
pub fn set_object_store_resolver(resolver: Arc<ObjectStoreResolver>) -> bool {
GLOBAL_OBJECT_STORE_RESOLVER.set(resolver).is_ok()
}
pub fn resolve_object_store_handle() -> Option<Arc<ECStore>> {
GLOBAL_OBJECT_STORE_RESOLVER
.get()
.and_then(|resolver| resolver())
.or_else(new_object_layer_fn)
}
/// Set the global object layer
///
/// # Arguments
+1 -1
View File
@@ -54,10 +54,10 @@ mod pools_test;
mod store_test;
pub mod tier;
pub use global::new_object_layer_fn;
pub use global::set_global_endpoints;
pub use global::update_erasure_type;
pub use global::{get_global_lock_client, get_global_lock_clients, set_global_lock_client, set_global_lock_clients};
pub use global::{new_object_layer_fn, resolve_object_store_handle, set_object_store_resolver};
pub use global::GLOBAL_Endpoints;
pub use store_api::StorageAPI;