diqiu50 commented on code in PR #6013:
URL: https://github.com/apache/gravitino/pull/6013#discussion_r1898191633


##########
clients/filesystem-fuse/src/config.rs:
##########
@@ -0,0 +1,324 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use crate::error::ErrorCode::{ConfigNotFound, InvalidConfig};
+use crate::utils::GvfsResult;
+use config::{builder, Config};
+use log::{info, warn};
+use serde::Deserialize;
+use std::collections::HashMap;
+use std::fs;
+
+const FUSE_DEFAULT_FILE_MASK: ConfigEntity<u32> = ConfigEntity::new(
+    FuseConfig::MODULE_NAME,
+    "default_file_mask",
+    "The default file mask for the FUSE filesystem",
+    0o600,
+);
+
+const FUSE_DEFAULT_DIR_MASK: ConfigEntity<u32> = ConfigEntity::new(
+    FuseConfig::MODULE_NAME,
+    "default_dir_mask",
+    "The default directory mask for the FUSE filesystem",
+    0o700,
+);
+
+const FUSE_FS_TYPE: ConfigEntity<&'static str> = ConfigEntity::new(
+    FuseConfig::MODULE_NAME,
+    "fs_type",
+    "The type of the FUSE filesystem",
+    "memory",
+);
+
+const FUSE_CONFIG_PATH: ConfigEntity<&'static str> = ConfigEntity::new(
+    FuseConfig::MODULE_NAME,
+    "config_path",
+    "The path of the FUSE configuration file",
+    "/etc/gvfs/gvfs.toml",
+);
+
+const FILESYSTEM_BLOCK_SIZE: ConfigEntity<u32> = ConfigEntity::new(
+    FilesystemConfig::MODULE_NAME,
+    "block_size",
+    "The block size of the gvfs fuse filesystem",
+    4096,
+);
+
+const GRAVITINO_URL: ConfigEntity<&'static str> = ConfigEntity::new(
+    GravitinoConfig::MODULE_NAME,
+    "gravitino_url",
+    "The URL of the Gravitino server",
+    "http://localhost:8090";,
+);
+
+const GRAVITINO_METALAKE: ConfigEntity<&'static str> = ConfigEntity::new(
+    GravitinoConfig::MODULE_NAME,
+    "metalake",
+    "The metalake of the Gravitino server",
+    "",
+);
+
+struct ConfigEntity<T: 'static> {
+    module: &'static str,
+    name: &'static str,
+    description: &'static str,
+    default: T,
+}
+
+impl<T> ConfigEntity<T> {
+    const fn new(
+        module: &'static str,
+        name: &'static str,
+        description: &'static str,
+        default: T,
+    ) -> Self {
+        ConfigEntity {
+            module: module,
+            name: name,
+            description: description,
+            default: default,
+        }
+    }
+}
+
+enum ConfigValue {
+    I32(ConfigEntity<i32>),
+    U32(ConfigEntity<u32>),
+    String(ConfigEntity<&'static str>),
+    Bool(ConfigEntity<bool>),
+    Float(ConfigEntity<f64>),
+}
+
+struct DefaultConfig {
+    configs: HashMap<String, ConfigValue>,
+}
+
+impl Default for DefaultConfig {
+    fn default() -> Self {
+        let mut configs = HashMap::new();
+
+        configs.insert(
+            Self::compose_key(FUSE_DEFAULT_FILE_MASK),
+            ConfigValue::U32(FUSE_DEFAULT_FILE_MASK),
+        );
+        configs.insert(
+            Self::compose_key(FUSE_DEFAULT_DIR_MASK),
+            ConfigValue::U32(FUSE_DEFAULT_DIR_MASK),
+        );
+        configs.insert(
+            Self::compose_key(FUSE_FS_TYPE),
+            ConfigValue::String(FUSE_FS_TYPE),
+        );
+        configs.insert(
+            Self::compose_key(FUSE_CONFIG_PATH),
+            ConfigValue::String(FUSE_CONFIG_PATH),
+        );
+        configs.insert(
+            Self::compose_key(GRAVITINO_URL),
+            ConfigValue::String(GRAVITINO_URL),
+        );
+        configs.insert(
+            Self::compose_key(GRAVITINO_METALAKE),
+            ConfigValue::String(GRAVITINO_METALAKE),
+        );
+        configs.insert(
+            Self::compose_key(FILESYSTEM_BLOCK_SIZE),
+            ConfigValue::U32(FILESYSTEM_BLOCK_SIZE),
+        );
+
+        DefaultConfig { configs }
+    }
+}
+
+impl DefaultConfig {
+    fn compose_key<T>(entity: ConfigEntity<T>) -> String {
+        format!("{}.{}", entity.module, entity.name)

Review Comment:
   There is no such restriction.



-- 
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