Xuanwo commented on code in PR #7196:
URL: https://github.com/apache/opendal/pull/7196#discussion_r2836316241


##########
core/core/src/types/operator/registry.rs:
##########
@@ -15,42 +15,38 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::collections::HashMap;
-use std::sync::{LazyLock, Mutex};
-
 use crate::types::builder::{Builder, Configurator};
 use crate::types::{IntoOperatorUri, OperatorUri};
 use crate::{Error, ErrorKind, Operator, Result};
+use std::collections::HashMap;
+use std::sync::{LazyLock, Mutex};
 
 /// Factory signature used to construct [`Operator`] from a URI and extra 
options.
 pub type OperatorFactory = fn(&OperatorUri) -> Result<Operator>;
 
-/// Default registry used by [`Operator::from_uri`].
-///
-/// `memory` is always registered here since it's used pervasively in unit 
tests
-/// and as a zero-dependency backend.
-///
-/// Other optional service registrations are handled by the facade crate 
`opendal`.
-pub static DEFAULT_OPERATOR_REGISTRY: LazyLock<OperatorRegistry> = 
LazyLock::new(|| {
-    let registry = OperatorRegistry::new();
-
-    crate::services::register_memory_service(&registry);
-
-    registry
-});
-
 /// Global registry that maps schemes to [`OperatorFactory`] functions.
-#[derive(Debug, Default)]
+#[derive(Debug)]
 pub struct OperatorRegistry {
     factories: Mutex<HashMap<String, OperatorFactory>>,
 }
 
 impl OperatorRegistry {
-    /// Create a new, empty registry.
-    pub fn new() -> Self {
-        Self {
-            factories: Mutex::new(HashMap::new()),
-        }
+    /// Get the global registry.
+    pub fn get() -> &'static Self {

Review Comment:
   I'm not sure if this is a good idea. Allowing users to build their own 
registry makes it easier for them to test and maintain it. They can even add 
custom logic, such as caching.
   
   But maybe it's always better than `DEFAULT_OPERATOR_REGISTRY`?



##########
core/Cargo.toml:
##########
@@ -83,6 +83,7 @@ all-features = true
 [features]
 blocking = ["opendal-core/blocking"]
 default = [
+  "register-services",

Review Comment:
   `register-services` is a bit confusing, how about something like 
`auto-register-services`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to