You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "tisonkun (via GitHub)" <gi...@apache.org> on 2024/08/22 09:19:06 UTC

[PR] feat: expose configs always [opendal]

tisonkun opened a new pull request, #5034:
URL: https://github.com/apache/opendal/pull/5034

   Resolve https://github.com/apache/opendal/issues/5033


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: expose configs always [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #5034:
URL: https://github.com/apache/opendal/pull/5034#discussion_r1726903109


##########
core/src/services/config.rs:
##########
@@ -0,0 +1,2047 @@
+// 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 serde::{Deserialize, Serialize};
+use std::fmt::{Debug, Formatter};
+use std::time::Duration;
+
+/// Config for Aliyun Drive services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AliyunDriveConfig {
+    /// The Root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// Default to `/` if not set.
+    pub root: Option<String>,
+    /// The access_token of this backend.
+    ///
+    /// Solution for client-only purpose. #4733
+    ///
+    /// Required if no client_id, client_secret and refresh_token are provided.
+    pub access_token: Option<String>,
+    /// The client_id of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub client_id: Option<String>,
+    /// The client_secret of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub client_secret: Option<String>,
+    /// The refresh_token of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub refresh_token: Option<String>,
+    /// The drive_type of this backend.
+    ///
+    /// All operations will happen under this type of drive.
+    ///
+    /// Available values are `default`, `backup` and `resource`.
+    ///
+    /// Fallback to default if not set or no other drives can be found.
+    pub drive_type: String,
+}
+
+impl Debug for AliyunDriveConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("AliyunDriveConfig");
+
+        d.field("root", &self.root)
+            .field("drive_type", &self.drive_type);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for alluxio services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AlluxioConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// default to `/` if not set.
+    pub root: Option<String>,
+    /// endpoint of this backend.
+    ///
+    /// Endpoint must be full uri, mostly like `http://127.0.0.1:39999`.
+    pub endpoint: Option<String>,
+}
+
+impl Debug for AlluxioConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("AlluxioConfig");
+
+        d.field("root", &self.root)
+            .field("endpoint", &self.endpoint);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for Atomicserver services support
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AtomicserverConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// private_key of this backend
+    pub private_key: Option<String>,
+    /// public_key of this backend
+    pub public_key: Option<String>,
+    /// parent_resource_id of this backend
+    pub parent_resource_id: Option<String>,
+}
+
+impl Debug for AtomicserverConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("AtomicserverConfig")
+            .field("root", &self.root)
+            .field("endpoint", &self.endpoint)
+            .field("public_key", &self.public_key)
+            .field("parent_resource_id", &self.parent_resource_id)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Azure Storage Blob services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzblobConfig {
+    /// The root of Azblob service backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+
+    /// The container name of Azblob service backend.
+    pub container: String,
+
+    /// The endpoint of Azblob service backend.
+    ///
+    /// Endpoint must be full uri, e.g.
+    ///
+    /// - Azblob: `https://accountname.blob.core.windows.net`
+    /// - Azurite: `http://127.0.0.1:10000/devstoreaccount1`
+    pub endpoint: Option<String>,
+
+    /// The account name of Azblob service backend.
+    pub account_name: Option<String>,
+
+    /// The account key of Azblob service backend.
+    pub account_key: Option<String>,
+
+    /// The encryption key of Azblob service backend.
+    pub encryption_key: Option<String>,
+
+    /// The encryption key sha256 of Azblob service backend.
+    pub encryption_key_sha256: Option<String>,
+
+    /// The encryption algorithm of Azblob service backend.
+    pub encryption_algorithm: Option<String>,
+
+    /// The sas token of Azblob service backend.
+    pub sas_token: Option<String>,
+
+    /// The maximum batch operations of Azblob service backend.
+    pub batch_max_operations: Option<usize>,
+}
+
+impl Debug for AzblobConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzblobConfig");
+
+        ds.field("root", &self.root);
+        ds.field("container", &self.container);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+        if self.sas_token.is_some() {
+            ds.field("sas_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Azure Data Lake Storage Gen2 Support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzdlsConfig {
+    /// Root of this backend.
+    pub root: Option<String>,
+    /// Filesystem name of this backend.
+    pub filesystem: String,
+    /// Endpoint of this backend.
+    pub endpoint: Option<String>,
+    /// Account name of this backend.
+    pub account_name: Option<String>,
+    /// Account key of this backend.
+    pub account_key: Option<String>,
+}
+
+impl Debug for AzdlsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzdlsConfig");
+
+        ds.field("root", &self.root);
+        ds.field("filesystem", &self.filesystem);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Azure File services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzfileConfig {
+    /// The root path for azfile.
+    pub root: Option<String>,
+    /// The endpoint for azfile.
+    pub endpoint: Option<String>,
+    /// The share name for azfile.
+    pub share_name: String,
+    /// The account name for azfile.
+    pub account_name: Option<String>,
+    /// The account key for azfile.
+    pub account_key: Option<String>,
+    /// The sas token for azfile.
+    pub sas_token: Option<String>,
+}
+
+impl Debug for AzfileConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzfileConfig");
+
+        ds.field("root", &self.root);
+        ds.field("share_name", &self.share_name);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+        if self.sas_token.is_some() {
+            ds.field("sas_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for backblaze b2 services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct B2Config {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// keyID of this backend.
+    ///
+    /// - If application_key_id is set, we will take user's input first.
+    /// - If not, we will try to load it from environment.
+    pub application_key_id: Option<String>,
+    /// applicationKey of this backend.
+    ///
+    /// - If application_key is set, we will take user's input first.
+    /// - If not, we will try to load it from environment.
+    pub application_key: Option<String>,
+    /// bucket of this backend.
+    ///
+    /// required.
+    pub bucket: String,
+    /// bucket id of this backend.
+    ///
+    /// required.
+    pub bucket_id: String,
+}
+
+impl Debug for B2Config {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("B2Config");
+
+        d.field("root", &self.root)
+            .field("application_key_id", &self.application_key_id)
+            .field("bucket_id", &self.bucket_id)
+            .field("bucket", &self.bucket);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// cacache service support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CacacheConfig {
+    /// That path to the cacache data directory.
+    pub datadir: Option<String>,
+}
+
+/// Config for Chainsafe services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct ChainsafeConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// api_key of this backend.
+    pub api_key: Option<String>,
+    /// bucket_id of this backend.
+    ///
+    /// required.
+    pub bucket_id: String,
+}
+
+impl Debug for ChainsafeConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("ChainsafeConfig");
+
+        d.field("root", &self.root)
+            .field("bucket_id", &self.bucket_id);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Cloudflare KV Service Support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CloudflareKvConfig {
+    /// The token used to authenticate with CloudFlare.
+    pub token: Option<String>,
+    /// The account ID used to authenticate with CloudFlare. Used as URI path parameter.
+    pub account_id: Option<String>,
+    /// The namespace ID. Used as URI path parameter.
+    pub namespace_id: Option<String>,
+
+    /// Root within this backend.
+    pub root: Option<String>,
+}
+
+impl Debug for CloudflareKvConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("CloudflareKvConfig");
+
+        ds.field("root", &self.root);
+        ds.field("account_id", &self.account_id);
+        ds.field("namespace_id", &self.namespace_id);
+
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// compio-based file system support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CompfsConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+}
+
+/// Tencent-Cloud COS services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+pub struct CosConfig {
+    /// Root of this backend.
+    pub root: Option<String>,
+    /// Endpoint of this backend.
+    pub endpoint: Option<String>,
+    /// Secret ID of this backend.
+    pub secret_id: Option<String>,
+    /// Secret key of this backend.
+    pub secret_key: Option<String>,
+    /// Bucket of this backend.
+    pub bucket: Option<String>,
+    /// Disable config load so that opendal will not load config from
+    pub disable_config_load: bool,
+}
+
+impl Debug for CosConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("CosConfig")
+            .field("root", &self.root)
+            .field("endpoint", &self.endpoint)
+            .field("secret_id", &"<redacted>")
+            .field("secret_key", &"<redacted>")
+            .field("bucket", &self.bucket)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for [Cloudflare D1](https://developers.cloudflare.com/d1) backend support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct D1Config {
+    /// Set the token of cloudflare api.
+    pub token: Option<String>,
+    /// Set the account id of cloudflare api.
+    pub account_id: Option<String>,
+    /// Set the database id of cloudflare api.
+    pub database_id: Option<String>,
+
+    /// Set the working directory of OpenDAL.
+    pub root: Option<String>,
+    /// Set the table of D1 Database.
+    pub table: Option<String>,
+    /// Set the key field of D1 Database.
+    pub key_field: Option<String>,
+    /// Set the value field of D1 Database.
+    pub value_field: Option<String>,
+}
+
+impl Debug for D1Config {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("D1Config");
+        ds.field("root", &self.root);
+        ds.field("table", &self.table);
+        ds.field("key_field", &self.key_field);
+        ds.field("value_field", &self.value_field);
+        ds.finish_non_exhaustive()
+    }
+}
+
+/// [dashmap](https://github.com/xacrimon/dashmap) backend support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct DashmapConfig {
+    /// The root path for dashmap.
+    pub root: Option<String>,
+}
+
+/// [Dbfs](https://docs.databricks.com/api/azure/workspace/dbfs)'s REST API support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct DbfsConfig {
+    /// The root for dbfs.
+    pub root: Option<String>,
+    /// The endpoint for dbfs.
+    pub endpoint: Option<String>,
+    /// The token for dbfs.
+    pub token: Option<String>,
+}
+
+impl Debug for DbfsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("DbfsConfig");
+
+        ds.field("root", &self.root);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for [Dropbox](https://www.dropbox.com/) backend support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct DropboxConfig {
+    /// root path for dropbox.
+    pub root: Option<String>,
+    /// access token for dropbox.
+    pub access_token: Option<String>,
+    /// refresh_token for dropbox.
+    pub refresh_token: Option<String>,
+    /// client_id for dropbox.
+    pub client_id: Option<String>,
+    /// client_secret for dropbox.
+    pub client_secret: Option<String>,
+}
+
+impl Debug for DropboxConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("DropBoxConfig")
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for Etcd services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct EtcdConfig {
+    /// network address of the Etcd services.
+    /// If use https, must set TLS options: `ca_path`, `cert_path`, `key_path`.
+    /// e.g. "127.0.0.1:23790,127.0.0.1:23791,127.0.0.1:23792" or "http://127.0.0.1:23790,http://127.0.0.1:23791,http://127.0.0.1:23792" or "https://127.0.0.1:23790,https://127.0.0.1:23791,https://127.0.0.1:23792"
+    ///
+    /// default is "http://127.0.0.1:2379"
+    pub endpoints: Option<String>,
+    /// the username to connect etcd service.
+    ///
+    /// default is None
+    pub username: Option<String>,
+    /// the password for authentication
+    ///
+    /// default is None
+    pub password: Option<String>,
+    /// the working directory of the etcd service. Can be "/path/to/dir"
+    ///
+    /// default is "/"
+    pub root: Option<String>,
+    /// certificate authority file path
+    ///
+    /// default is None
+    pub ca_path: Option<String>,
+    /// cert path
+    ///
+    /// default is None
+    pub cert_path: Option<String>,
+    /// key path
+    ///
+    /// default is None
+    pub key_path: Option<String>,
+}
+
+impl Debug for EtcdConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("EtcdConfig");
+
+        ds.field("root", &self.root);
+        if let Some(endpoints) = self.endpoints.clone() {
+            ds.field("endpoints", &endpoints);
+        }
+        if let Some(username) = self.username.clone() {
+            ds.field("username", &username);
+        }
+        if self.password.is_some() {
+            ds.field("password", &"<redacted>");
+        }
+        if let Some(ca_path) = self.ca_path.clone() {
+            ds.field("ca_path", &ca_path);
+        }
+        if let Some(cert_path) = self.cert_path.clone() {
+            ds.field("cert_path", &cert_path);
+        }
+        if let Some(key_path) = self.key_path.clone() {
+            ds.field("key_path", &key_path);
+        }
+        ds.finish()
+    }
+}
+
+/// [foundationdb](https://www.foundationdb.org/) service support.
+///Config for FoundationDB.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FoundationdbConfig {
+    ///root of the backend.
+    pub root: Option<String>,
+    ///config_path for the backend.
+    pub config_path: Option<String>,
+}
+
+impl Debug for FoundationdbConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("FoundationConfig");
+
+        ds.field("root", &self.root);
+        ds.field("config_path", &self.config_path);
+
+        ds.finish()
+    }
+}
+
+/// config for file system
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FsConfig {
+    /// root dir for backend
+    pub root: Option<String>,
+
+    /// tmp dir for atomic write
+    pub atomic_write_dir: Option<String>,
+}
+
+/// Config for Ftp services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FtpConfig {
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// root of this backend
+    pub root: Option<String>,
+    /// user of this backend
+    pub user: Option<String>,
+    /// password of this backend
+    pub password: Option<String>,
+}
+
+impl Debug for FtpConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("FtpConfig")
+            .field("endpoint", &self.endpoint)
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// [Google Cloud Storage](https://cloud.google.com/storage) services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GcsConfig {
+    /// root URI, all operations happens under `root`
+    pub root: Option<String>,
+    /// bucket name
+    pub bucket: String,
+    /// endpoint URI of GCS service,
+    /// default is `https://storage.googleapis.com`
+    pub endpoint: Option<String>,
+    /// Scope for gcs.
+    pub scope: Option<String>,
+    /// Service Account for gcs.
+    pub service_account: Option<String>,
+    /// Credentials string for GCS service OAuth2 authentication.
+    pub credential: Option<String>,
+    /// Local path to credentials file for GCS service OAuth2 authentication.
+    pub credential_path: Option<String>,
+    /// The predefined acl for GCS.
+    pub predefined_acl: Option<String>,
+    /// The default storage class used by gcs.
+    pub default_storage_class: Option<String>,
+    /// Allow opendal to send requests without signing when credentials are not
+    /// loaded.
+    pub allow_anonymous: bool,
+    /// Disable attempting to load credentials from the GCE metadata server when
+    /// running within Google Cloud.
+    pub disable_vm_metadata: bool,
+    /// Disable loading configuration from the environment.
+    pub disable_config_load: bool,
+    /// A Google Cloud OAuth2 token.
+    ///
+    /// Takes precedence over `credential` and `credential_path`.
+    pub token: Option<String>,
+}
+
+impl Debug for GcsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GcsConfig")
+            .field("root", &self.root)
+            .field("bucket", &self.bucket)
+            .field("endpoint", &self.endpoint)
+            .field("scope", &self.scope)
+            .finish_non_exhaustive()
+    }
+}
+
+/// [GoogleDrive](https://drive.google.com/) configuration.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GdriveConfig {
+    /// The root for gdrive
+    pub root: Option<String>,
+    /// Access token for gdrive.
+    pub access_token: Option<String>,
+    /// Refresh token for gdrive.
+    pub refresh_token: Option<String>,
+    /// Client id for gdrive.
+    pub client_id: Option<String>,
+    /// Client secret for gdrive.
+    pub client_secret: Option<String>,
+}
+
+impl Debug for GdriveConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GdriveConfig")
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for GitHub Action Cache Services support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GhacConfig {
+    /// The root path for ghac.
+    pub root: Option<String>,
+    /// The version that used by cache.
+    pub version: Option<String>,
+    /// The endpoint for ghac service.
+    pub endpoint: Option<String>,
+    /// The runtime token for ghac service.
+    pub runtime_token: Option<String>,
+}
+
+/// Config for GitHub services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GithubConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// GitHub access_token.
+    ///
+    /// optional.
+    /// If not provided, the backend will only support read operations for public repositories.
+    /// And rate limit will be limited to 60 requests per hour.
+    pub token: Option<String>,
+    /// GitHub repo owner.
+    ///
+    /// required.
+    pub owner: String,
+    /// GitHub repo name.
+    ///
+    /// required.
+    pub repo: String,
+}
+
+impl Debug for GithubConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("GithubConfig");
+
+        d.field("root", &self.root)
+            .field("owner", &self.owner)
+            .field("repo", &self.repo);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for Grid file system support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GridFsConfig {
+    /// The connection string of the MongoDB service.
+    pub connection_string: Option<String>,
+    /// The database name of the MongoDB GridFs service to read/write.
+    pub database: Option<String>,
+    /// The bucket name of the MongoDB GridFs service to read/write.
+    pub bucket: Option<String>,
+    /// The chunk size of the MongoDB GridFs service used to break the user file into chunks.
+    pub chunk_size: Option<u32>,
+    /// The working directory, all operations will be performed under it.
+    pub root: Option<String>,
+}
+
+impl Debug for GridFsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GridFsConfig")
+            .field("database", &self.database)
+            .field("bucket", &self.bucket)
+            .field("chunk_size", &self.chunk_size)
+            .field("root", &self.root)
+            .finish()
+    }
+}
+
+/// [Hadoop Distributed File System (HDFS™)](https://hadoop.apache.org/) support.
+///
+/// Config for Hdfs services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HdfsConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// name node of this backend
+    pub name_node: Option<String>,
+    /// kerberos_ticket_cache_path of this backend
+    pub kerberos_ticket_cache_path: Option<String>,
+    /// user of this backend
+    pub user: Option<String>,
+    /// enable the append capacity
+    pub enable_append: bool,
+    /// atomic_write_dir of this backend
+    pub atomic_write_dir: Option<String>,
+}
+
+impl Debug for HdfsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("HdfsConfig")
+            .field("root", &self.root)
+            .field("name_node", &self.name_node)
+            .field(
+                "kerberos_ticket_cache_path",
+                &self.kerberos_ticket_cache_path,
+            )
+            .field("user", &self.user)
+            .field("enable_append", &self.enable_append)
+            .field("atomic_write_dir", &self.atomic_write_dir)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for HdfsNative services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HdfsNativeConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// url of this backend
+    pub url: Option<String>,
+    /// enable the append capacity
+    pub enable_append: bool,
+}
+
+impl Debug for HdfsNativeConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("HdfsNativeConfig")
+            .field("root", &self.root)
+            .field("url", &self.url)
+            .field("enable_append", &self.enable_append)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for Http service support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HttpConfig {
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// username of this backend
+    pub username: Option<String>,
+    /// password of this backend
+    pub password: Option<String>,
+    /// token of this backend
+    pub token: Option<String>,
+    /// root of this backend
+    pub root: Option<String>,
+}
+
+impl Debug for HttpConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut de = f.debug_struct("HttpConfig");
+        de.field("endpoint", &self.endpoint);
+        de.field("root", &self.root);
+
+        de.finish_non_exhaustive()
+    }
+}
+
+/// Configuration for Huggingface service support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HuggingfaceConfig {
+    /// Repo type of this backend. Default is model.
+    ///
+    /// Available values:
+    /// - model
+    /// - dataset
+    pub repo_type: Option<String>,
+    /// Repo id of this backend.
+    ///
+    /// This is required.
+    pub repo_id: Option<String>,
+    /// Revision of this backend.
+    ///
+    /// Default is main.
+    pub revision: Option<String>,
+    /// Root of this backend. Can be "/path/to/dir".
+    ///
+    /// Default is "/".
+    pub root: Option<String>,
+    /// Token of this backend.
+    ///
+    /// This is optional.
+    pub token: Option<String>,
+}
+
+impl Debug for HuggingfaceConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("HuggingfaceConfig");
+
+        if let Some(repo_type) = &self.repo_type {
+            ds.field("repo_type", &repo_type);
+        }
+        if let Some(repo_id) = &self.repo_id {
+            ds.field("repo_id", &repo_id);
+        }
+        if let Some(revision) = &self.revision {
+            ds.field("revision", &revision);
+        }
+        if let Some(root) = &self.root {
+            ds.field("root", &root);
+        }
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for icloud services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IcloudConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// default to `/` if not set.
+    pub root: Option<String>,
+    /// apple_id of this backend.
+    ///
+    /// apple_id must be full, mostly like `example@gmail.com`.
+    pub apple_id: Option<String>,
+    /// password of this backend.
+    ///
+    /// password must be full.
+    pub password: Option<String>,
+
+    /// Session
+    ///
+    /// token must be valid.
+    pub trust_token: Option<String>,
+    /// ds_web_auth_token must be set in Session
+    pub ds_web_auth_token: Option<String>,
+    /// enable the china origin
+    /// China region `origin` Header needs to be set to "https://www.icloud.com.cn".
+    ///
+    /// otherwise Apple server will return 302.
+    pub is_china_mainland: bool,
+}
+
+impl Debug for IcloudConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("IcloudBuilder");
+        d.field("root", &self.root);
+        d.field("is_china_mainland", &self.is_china_mainland);
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for IPFS file system support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IpfsConfig {
+    /// IPFS gateway endpoint.
+    pub endpoint: Option<String>,
+    /// IPFS root.
+    pub root: Option<String>,
+}
+
+/// Config for IPFS MFS support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IpmfsConfig {
+    /// Root for ipfs.
+    pub root: Option<String>,
+    /// Endpoint for ipfs.
+    pub endpoint: Option<String>,
+}
+
+/// Config for Koofr services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct KoofrConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// Koofr endpoint.
+    pub endpoint: String,
+    /// Koofr email.
+    pub email: String,
+    /// password of this backend. (Must be the application password)
+    pub password: Option<String>,
+}
+
+impl Debug for KoofrConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("Config");
+
+        ds.field("root", &self.root);
+        ds.field("email", &self.email);
+
+        ds.finish()
+    }
+}
+
+/// Config for Libsql services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct LibsqlConfig {
+    /// Connection string for libsql service.
+    pub connection_string: Option<String>,
+    /// Authentication token for libsql service.
+    pub auth_token: Option<String>,
+
+    /// Table name for libsql service.
+    pub table: Option<String>,
+    /// Key field name for libsql service.
+    pub key_field: Option<String>,
+    /// Value field name for libsql service.
+    pub value_field: Option<String>,
+    /// Root for libsql service.
+    pub root: Option<String>,
+}
+
+impl Debug for LibsqlConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("LibsqlConfig");
+        ds.field("connection_string", &self.connection_string)
+            .field("table", &self.table)
+            .field("key_field", &self.key_field)
+            .field("value_field", &self.value_field)
+            .field("root", &self.root);
+
+        if self.auth_token.is_some() {
+            ds.field("auth_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for MemCached services support
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MemcachedConfig {
+    /// network address of the memcached service.
+    ///
+    /// For example: "tcp://localhost:11211"
+    pub endpoint: Option<String>,
+    /// the working directory of the service. Can be "/path/to/dir"
+    ///
+    /// default is "/"
+    pub root: Option<String>,
+    /// Memcached username, optional.
+    pub username: Option<String>,
+    /// Memcached password, optional.
+    pub password: Option<String>,
+    /// The default ttl for put operations.
+    pub default_ttl: Option<Duration>,
+}
+
+/// Config for memory.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MemoryConfig {
+    /// root of the backend.
+    pub root: Option<String>,
+}
+
+/// Config for mini-moka support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MiniMokaConfig {
+    /// Sets the max capacity of the cache.
+    ///
+    /// Refer to [`mini-moka::sync::CacheBuilder::max_capacity`](https://docs.rs/mini-moka/latest/mini_moka/sync/struct.CacheBuilder.html#method.max_capacity)
+    pub max_capacity: Option<u64>,
+    /// Sets the time to live of the cache.
+    ///
+    /// Refer to [`mini-moka::sync::CacheBuilder::time_to_live`](https://docs.rs/mini-moka/latest/mini_moka/sync/struct.CacheBuilder.html#method.time_to_live)
+    pub time_to_live: Option<Duration>,

Review Comment:
   I'm considering using an `int` directly instead of exposing `Duration`. What do you think?



-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(core): expose configs always [opendal]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #5034:
URL: https://github.com/apache/opendal/pull/5034#issuecomment-2306625960

   @Xuanwo let's give an approval and move forward.


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: expose configs always [opendal]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #5034:
URL: https://github.com/apache/opendal/pull/5034#discussion_r1726748509


##########
core/src/services/config.rs:
##########
@@ -0,0 +1,2047 @@
+// 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 serde::{Deserialize, Serialize};
+use std::fmt::{Debug, Formatter};
+use std::time::Duration;
+
+/// Config for Aliyun Drive services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AliyunDriveConfig {
+    /// The Root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// Default to `/` if not set.
+    pub root: Option<String>,
+    /// The access_token of this backend.
+    ///
+    /// Solution for client-only purpose. #4733
+    ///
+    /// Required if no client_id, client_secret and refresh_token are provided.
+    pub access_token: Option<String>,
+    /// The client_id of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub client_id: Option<String>,
+    /// The client_secret of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub client_secret: Option<String>,
+    /// The refresh_token of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub refresh_token: Option<String>,
+    /// The drive_type of this backend.
+    ///
+    /// All operations will happen under this type of drive.
+    ///
+    /// Available values are `default`, `backup` and `resource`.
+    ///
+    /// Fallback to default if not set or no other drives can be found.
+    pub drive_type: String,
+}
+
+impl Debug for AliyunDriveConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("AliyunDriveConfig");
+
+        d.field("root", &self.root)
+            .field("drive_type", &self.drive_type);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for alluxio services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AlluxioConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// default to `/` if not set.
+    pub root: Option<String>,
+    /// endpoint of this backend.
+    ///
+    /// Endpoint must be full uri, mostly like `http://127.0.0.1:39999`.
+    pub endpoint: Option<String>,
+}
+
+impl Debug for AlluxioConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("AlluxioConfig");
+
+        d.field("root", &self.root)
+            .field("endpoint", &self.endpoint);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for Atomicserver services support
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AtomicserverConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// private_key of this backend
+    pub private_key: Option<String>,
+    /// public_key of this backend
+    pub public_key: Option<String>,
+    /// parent_resource_id of this backend
+    pub parent_resource_id: Option<String>,
+}
+
+impl Debug for AtomicserverConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("AtomicserverConfig")
+            .field("root", &self.root)
+            .field("endpoint", &self.endpoint)
+            .field("public_key", &self.public_key)
+            .field("parent_resource_id", &self.parent_resource_id)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Azure Storage Blob services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzblobConfig {
+    /// The root of Azblob service backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+
+    /// The container name of Azblob service backend.
+    pub container: String,
+
+    /// The endpoint of Azblob service backend.
+    ///
+    /// Endpoint must be full uri, e.g.
+    ///
+    /// - Azblob: `https://accountname.blob.core.windows.net`
+    /// - Azurite: `http://127.0.0.1:10000/devstoreaccount1`
+    pub endpoint: Option<String>,
+
+    /// The account name of Azblob service backend.
+    pub account_name: Option<String>,
+
+    /// The account key of Azblob service backend.
+    pub account_key: Option<String>,
+
+    /// The encryption key of Azblob service backend.
+    pub encryption_key: Option<String>,
+
+    /// The encryption key sha256 of Azblob service backend.
+    pub encryption_key_sha256: Option<String>,
+
+    /// The encryption algorithm of Azblob service backend.
+    pub encryption_algorithm: Option<String>,
+
+    /// The sas token of Azblob service backend.
+    pub sas_token: Option<String>,
+
+    /// The maximum batch operations of Azblob service backend.
+    pub batch_max_operations: Option<usize>,
+}
+
+impl Debug for AzblobConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzblobConfig");
+
+        ds.field("root", &self.root);
+        ds.field("container", &self.container);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+        if self.sas_token.is_some() {
+            ds.field("sas_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Azure Data Lake Storage Gen2 Support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzdlsConfig {
+    /// Root of this backend.
+    pub root: Option<String>,
+    /// Filesystem name of this backend.
+    pub filesystem: String,
+    /// Endpoint of this backend.
+    pub endpoint: Option<String>,
+    /// Account name of this backend.
+    pub account_name: Option<String>,
+    /// Account key of this backend.
+    pub account_key: Option<String>,
+}
+
+impl Debug for AzdlsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzdlsConfig");
+
+        ds.field("root", &self.root);
+        ds.field("filesystem", &self.filesystem);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Azure File services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzfileConfig {
+    /// The root path for azfile.
+    pub root: Option<String>,
+    /// The endpoint for azfile.
+    pub endpoint: Option<String>,
+    /// The share name for azfile.
+    pub share_name: String,
+    /// The account name for azfile.
+    pub account_name: Option<String>,
+    /// The account key for azfile.
+    pub account_key: Option<String>,
+    /// The sas token for azfile.
+    pub sas_token: Option<String>,
+}
+
+impl Debug for AzfileConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzfileConfig");
+
+        ds.field("root", &self.root);
+        ds.field("share_name", &self.share_name);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+        if self.sas_token.is_some() {
+            ds.field("sas_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for backblaze b2 services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct B2Config {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// keyID of this backend.
+    ///
+    /// - If application_key_id is set, we will take user's input first.
+    /// - If not, we will try to load it from environment.
+    pub application_key_id: Option<String>,
+    /// applicationKey of this backend.
+    ///
+    /// - If application_key is set, we will take user's input first.
+    /// - If not, we will try to load it from environment.
+    pub application_key: Option<String>,
+    /// bucket of this backend.
+    ///
+    /// required.
+    pub bucket: String,
+    /// bucket id of this backend.
+    ///
+    /// required.
+    pub bucket_id: String,
+}
+
+impl Debug for B2Config {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("B2Config");
+
+        d.field("root", &self.root)
+            .field("application_key_id", &self.application_key_id)
+            .field("bucket_id", &self.bucket_id)
+            .field("bucket", &self.bucket);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// cacache service support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CacacheConfig {
+    /// That path to the cacache data directory.
+    pub datadir: Option<String>,
+}
+
+/// Config for Chainsafe services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct ChainsafeConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// api_key of this backend.
+    pub api_key: Option<String>,
+    /// bucket_id of this backend.
+    ///
+    /// required.
+    pub bucket_id: String,
+}
+
+impl Debug for ChainsafeConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("ChainsafeConfig");
+
+        d.field("root", &self.root)
+            .field("bucket_id", &self.bucket_id);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Cloudflare KV Service Support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CloudflareKvConfig {
+    /// The token used to authenticate with CloudFlare.
+    pub token: Option<String>,
+    /// The account ID used to authenticate with CloudFlare. Used as URI path parameter.
+    pub account_id: Option<String>,
+    /// The namespace ID. Used as URI path parameter.
+    pub namespace_id: Option<String>,
+
+    /// Root within this backend.
+    pub root: Option<String>,
+}
+
+impl Debug for CloudflareKvConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("CloudflareKvConfig");
+
+        ds.field("root", &self.root);
+        ds.field("account_id", &self.account_id);
+        ds.field("namespace_id", &self.namespace_id);
+
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// compio-based file system support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CompfsConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+}
+
+/// Tencent-Cloud COS services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+pub struct CosConfig {
+    /// Root of this backend.
+    pub root: Option<String>,
+    /// Endpoint of this backend.
+    pub endpoint: Option<String>,
+    /// Secret ID of this backend.
+    pub secret_id: Option<String>,
+    /// Secret key of this backend.
+    pub secret_key: Option<String>,
+    /// Bucket of this backend.
+    pub bucket: Option<String>,
+    /// Disable config load so that opendal will not load config from
+    pub disable_config_load: bool,
+}
+
+impl Debug for CosConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("CosConfig")
+            .field("root", &self.root)
+            .field("endpoint", &self.endpoint)
+            .field("secret_id", &"<redacted>")
+            .field("secret_key", &"<redacted>")
+            .field("bucket", &self.bucket)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for [Cloudflare D1](https://developers.cloudflare.com/d1) backend support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct D1Config {
+    /// Set the token of cloudflare api.
+    pub token: Option<String>,
+    /// Set the account id of cloudflare api.
+    pub account_id: Option<String>,
+    /// Set the database id of cloudflare api.
+    pub database_id: Option<String>,
+
+    /// Set the working directory of OpenDAL.
+    pub root: Option<String>,
+    /// Set the table of D1 Database.
+    pub table: Option<String>,
+    /// Set the key field of D1 Database.
+    pub key_field: Option<String>,
+    /// Set the value field of D1 Database.
+    pub value_field: Option<String>,
+}
+
+impl Debug for D1Config {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("D1Config");
+        ds.field("root", &self.root);
+        ds.field("table", &self.table);
+        ds.field("key_field", &self.key_field);
+        ds.field("value_field", &self.value_field);
+        ds.finish_non_exhaustive()
+    }
+}
+
+/// [dashmap](https://github.com/xacrimon/dashmap) backend support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct DashmapConfig {
+    /// The root path for dashmap.
+    pub root: Option<String>,
+}
+
+/// [Dbfs](https://docs.databricks.com/api/azure/workspace/dbfs)'s REST API support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct DbfsConfig {
+    /// The root for dbfs.
+    pub root: Option<String>,
+    /// The endpoint for dbfs.
+    pub endpoint: Option<String>,
+    /// The token for dbfs.
+    pub token: Option<String>,
+}
+
+impl Debug for DbfsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("DbfsConfig");
+
+        ds.field("root", &self.root);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for [Dropbox](https://www.dropbox.com/) backend support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct DropboxConfig {
+    /// root path for dropbox.
+    pub root: Option<String>,
+    /// access token for dropbox.
+    pub access_token: Option<String>,
+    /// refresh_token for dropbox.
+    pub refresh_token: Option<String>,
+    /// client_id for dropbox.
+    pub client_id: Option<String>,
+    /// client_secret for dropbox.
+    pub client_secret: Option<String>,
+}
+
+impl Debug for DropboxConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("DropBoxConfig")
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for Etcd services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct EtcdConfig {
+    /// network address of the Etcd services.
+    /// If use https, must set TLS options: `ca_path`, `cert_path`, `key_path`.
+    /// e.g. "127.0.0.1:23790,127.0.0.1:23791,127.0.0.1:23792" or "http://127.0.0.1:23790,http://127.0.0.1:23791,http://127.0.0.1:23792" or "https://127.0.0.1:23790,https://127.0.0.1:23791,https://127.0.0.1:23792"
+    ///
+    /// default is "http://127.0.0.1:2379"
+    pub endpoints: Option<String>,
+    /// the username to connect etcd service.
+    ///
+    /// default is None
+    pub username: Option<String>,
+    /// the password for authentication
+    ///
+    /// default is None
+    pub password: Option<String>,
+    /// the working directory of the etcd service. Can be "/path/to/dir"
+    ///
+    /// default is "/"
+    pub root: Option<String>,
+    /// certificate authority file path
+    ///
+    /// default is None
+    pub ca_path: Option<String>,
+    /// cert path
+    ///
+    /// default is None
+    pub cert_path: Option<String>,
+    /// key path
+    ///
+    /// default is None
+    pub key_path: Option<String>,
+}
+
+impl Debug for EtcdConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("EtcdConfig");
+
+        ds.field("root", &self.root);
+        if let Some(endpoints) = self.endpoints.clone() {
+            ds.field("endpoints", &endpoints);
+        }
+        if let Some(username) = self.username.clone() {
+            ds.field("username", &username);
+        }
+        if self.password.is_some() {
+            ds.field("password", &"<redacted>");
+        }
+        if let Some(ca_path) = self.ca_path.clone() {
+            ds.field("ca_path", &ca_path);
+        }
+        if let Some(cert_path) = self.cert_path.clone() {
+            ds.field("cert_path", &cert_path);
+        }
+        if let Some(key_path) = self.key_path.clone() {
+            ds.field("key_path", &key_path);
+        }
+        ds.finish()
+    }
+}
+
+/// [foundationdb](https://www.foundationdb.org/) service support.
+///Config for FoundationDB.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FoundationdbConfig {
+    ///root of the backend.
+    pub root: Option<String>,
+    ///config_path for the backend.
+    pub config_path: Option<String>,
+}
+
+impl Debug for FoundationdbConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("FoundationConfig");
+
+        ds.field("root", &self.root);
+        ds.field("config_path", &self.config_path);
+
+        ds.finish()
+    }
+}
+
+/// config for file system
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FsConfig {
+    /// root dir for backend
+    pub root: Option<String>,
+
+    /// tmp dir for atomic write
+    pub atomic_write_dir: Option<String>,
+}
+
+/// Config for Ftp services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FtpConfig {
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// root of this backend
+    pub root: Option<String>,
+    /// user of this backend
+    pub user: Option<String>,
+    /// password of this backend
+    pub password: Option<String>,
+}
+
+impl Debug for FtpConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("FtpConfig")
+            .field("endpoint", &self.endpoint)
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// [Google Cloud Storage](https://cloud.google.com/storage) services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GcsConfig {
+    /// root URI, all operations happens under `root`
+    pub root: Option<String>,
+    /// bucket name
+    pub bucket: String,
+    /// endpoint URI of GCS service,
+    /// default is `https://storage.googleapis.com`
+    pub endpoint: Option<String>,
+    /// Scope for gcs.
+    pub scope: Option<String>,
+    /// Service Account for gcs.
+    pub service_account: Option<String>,
+    /// Credentials string for GCS service OAuth2 authentication.
+    pub credential: Option<String>,
+    /// Local path to credentials file for GCS service OAuth2 authentication.
+    pub credential_path: Option<String>,
+    /// The predefined acl for GCS.
+    pub predefined_acl: Option<String>,
+    /// The default storage class used by gcs.
+    pub default_storage_class: Option<String>,
+    /// Allow opendal to send requests without signing when credentials are not
+    /// loaded.
+    pub allow_anonymous: bool,
+    /// Disable attempting to load credentials from the GCE metadata server when
+    /// running within Google Cloud.
+    pub disable_vm_metadata: bool,
+    /// Disable loading configuration from the environment.
+    pub disable_config_load: bool,
+    /// A Google Cloud OAuth2 token.
+    ///
+    /// Takes precedence over `credential` and `credential_path`.
+    pub token: Option<String>,
+}
+
+impl Debug for GcsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GcsConfig")
+            .field("root", &self.root)
+            .field("bucket", &self.bucket)
+            .field("endpoint", &self.endpoint)
+            .field("scope", &self.scope)
+            .finish_non_exhaustive()
+    }
+}
+
+/// [GoogleDrive](https://drive.google.com/) configuration.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GdriveConfig {
+    /// The root for gdrive
+    pub root: Option<String>,
+    /// Access token for gdrive.
+    pub access_token: Option<String>,
+    /// Refresh token for gdrive.
+    pub refresh_token: Option<String>,
+    /// Client id for gdrive.
+    pub client_id: Option<String>,
+    /// Client secret for gdrive.
+    pub client_secret: Option<String>,
+}
+
+impl Debug for GdriveConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GdriveConfig")
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for GitHub Action Cache Services support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GhacConfig {
+    /// The root path for ghac.
+    pub root: Option<String>,
+    /// The version that used by cache.
+    pub version: Option<String>,
+    /// The endpoint for ghac service.
+    pub endpoint: Option<String>,
+    /// The runtime token for ghac service.
+    pub runtime_token: Option<String>,
+}
+
+/// Config for GitHub services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GithubConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// GitHub access_token.
+    ///
+    /// optional.
+    /// If not provided, the backend will only support read operations for public repositories.
+    /// And rate limit will be limited to 60 requests per hour.
+    pub token: Option<String>,
+    /// GitHub repo owner.
+    ///
+    /// required.
+    pub owner: String,
+    /// GitHub repo name.
+    ///
+    /// required.
+    pub repo: String,
+}
+
+impl Debug for GithubConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("GithubConfig");
+
+        d.field("root", &self.root)
+            .field("owner", &self.owner)
+            .field("repo", &self.repo);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for Grid file system support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GridFsConfig {
+    /// The connection string of the MongoDB service.
+    pub connection_string: Option<String>,
+    /// The database name of the MongoDB GridFs service to read/write.
+    pub database: Option<String>,
+    /// The bucket name of the MongoDB GridFs service to read/write.
+    pub bucket: Option<String>,
+    /// The chunk size of the MongoDB GridFs service used to break the user file into chunks.
+    pub chunk_size: Option<u32>,
+    /// The working directory, all operations will be performed under it.
+    pub root: Option<String>,
+}
+
+impl Debug for GridFsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GridFsConfig")
+            .field("database", &self.database)
+            .field("bucket", &self.bucket)
+            .field("chunk_size", &self.chunk_size)
+            .field("root", &self.root)
+            .finish()
+    }
+}
+
+/// [Hadoop Distributed File System (HDFS™)](https://hadoop.apache.org/) support.
+///
+/// Config for Hdfs services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HdfsConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// name node of this backend
+    pub name_node: Option<String>,
+    /// kerberos_ticket_cache_path of this backend
+    pub kerberos_ticket_cache_path: Option<String>,
+    /// user of this backend
+    pub user: Option<String>,
+    /// enable the append capacity
+    pub enable_append: bool,
+    /// atomic_write_dir of this backend
+    pub atomic_write_dir: Option<String>,
+}
+
+impl Debug for HdfsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("HdfsConfig")
+            .field("root", &self.root)
+            .field("name_node", &self.name_node)
+            .field(
+                "kerberos_ticket_cache_path",
+                &self.kerberos_ticket_cache_path,
+            )
+            .field("user", &self.user)
+            .field("enable_append", &self.enable_append)
+            .field("atomic_write_dir", &self.atomic_write_dir)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for HdfsNative services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HdfsNativeConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// url of this backend
+    pub url: Option<String>,
+    /// enable the append capacity
+    pub enable_append: bool,
+}
+
+impl Debug for HdfsNativeConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("HdfsNativeConfig")
+            .field("root", &self.root)
+            .field("url", &self.url)
+            .field("enable_append", &self.enable_append)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for Http service support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HttpConfig {
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// username of this backend
+    pub username: Option<String>,
+    /// password of this backend
+    pub password: Option<String>,
+    /// token of this backend
+    pub token: Option<String>,
+    /// root of this backend
+    pub root: Option<String>,
+}
+
+impl Debug for HttpConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut de = f.debug_struct("HttpConfig");
+        de.field("endpoint", &self.endpoint);
+        de.field("root", &self.root);
+
+        de.finish_non_exhaustive()
+    }
+}
+
+/// Configuration for Huggingface service support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HuggingfaceConfig {
+    /// Repo type of this backend. Default is model.
+    ///
+    /// Available values:
+    /// - model
+    /// - dataset
+    pub repo_type: Option<String>,
+    /// Repo id of this backend.
+    ///
+    /// This is required.
+    pub repo_id: Option<String>,
+    /// Revision of this backend.
+    ///
+    /// Default is main.
+    pub revision: Option<String>,
+    /// Root of this backend. Can be "/path/to/dir".
+    ///
+    /// Default is "/".
+    pub root: Option<String>,
+    /// Token of this backend.
+    ///
+    /// This is optional.
+    pub token: Option<String>,
+}
+
+impl Debug for HuggingfaceConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("HuggingfaceConfig");
+
+        if let Some(repo_type) = &self.repo_type {
+            ds.field("repo_type", &repo_type);
+        }
+        if let Some(repo_id) = &self.repo_id {
+            ds.field("repo_id", &repo_id);
+        }
+        if let Some(revision) = &self.revision {
+            ds.field("revision", &revision);
+        }
+        if let Some(root) = &self.root {
+            ds.field("root", &root);
+        }
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for icloud services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IcloudConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// default to `/` if not set.
+    pub root: Option<String>,
+    /// apple_id of this backend.
+    ///
+    /// apple_id must be full, mostly like `example@gmail.com`.
+    pub apple_id: Option<String>,
+    /// password of this backend.
+    ///
+    /// password must be full.
+    pub password: Option<String>,
+
+    /// Session
+    ///
+    /// token must be valid.
+    pub trust_token: Option<String>,
+    /// ds_web_auth_token must be set in Session
+    pub ds_web_auth_token: Option<String>,
+    /// enable the china origin
+    /// China region `origin` Header needs to be set to "https://www.icloud.com.cn".
+    ///
+    /// otherwise Apple server will return 302.
+    pub is_china_mainland: bool,
+}
+
+impl Debug for IcloudConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("IcloudBuilder");
+        d.field("root", &self.root);
+        d.field("is_china_mainland", &self.is_china_mainland);
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for IPFS file system support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IpfsConfig {
+    /// IPFS gateway endpoint.
+    pub endpoint: Option<String>,
+    /// IPFS root.
+    pub root: Option<String>,
+}
+
+/// Config for IPFS MFS support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IpmfsConfig {
+    /// Root for ipfs.
+    pub root: Option<String>,
+    /// Endpoint for ipfs.
+    pub endpoint: Option<String>,
+}
+
+/// Config for Koofr services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct KoofrConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// Koofr endpoint.
+    pub endpoint: String,
+    /// Koofr email.
+    pub email: String,
+    /// password of this backend. (Must be the application password)
+    pub password: Option<String>,
+}
+
+impl Debug for KoofrConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("Config");
+
+        ds.field("root", &self.root);
+        ds.field("email", &self.email);
+
+        ds.finish()
+    }
+}
+
+/// Config for Libsql services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct LibsqlConfig {
+    /// Connection string for libsql service.
+    pub connection_string: Option<String>,
+    /// Authentication token for libsql service.
+    pub auth_token: Option<String>,
+
+    /// Table name for libsql service.
+    pub table: Option<String>,
+    /// Key field name for libsql service.
+    pub key_field: Option<String>,
+    /// Value field name for libsql service.
+    pub value_field: Option<String>,
+    /// Root for libsql service.
+    pub root: Option<String>,
+}
+
+impl Debug for LibsqlConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("LibsqlConfig");
+        ds.field("connection_string", &self.connection_string)
+            .field("table", &self.table)
+            .field("key_field", &self.key_field)
+            .field("value_field", &self.value_field)
+            .field("root", &self.root);
+
+        if self.auth_token.is_some() {
+            ds.field("auth_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for MemCached services support
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MemcachedConfig {
+    /// network address of the memcached service.
+    ///
+    /// For example: "tcp://localhost:11211"
+    pub endpoint: Option<String>,
+    /// the working directory of the service. Can be "/path/to/dir"
+    ///
+    /// default is "/"
+    pub root: Option<String>,
+    /// Memcached username, optional.
+    pub username: Option<String>,
+    /// Memcached password, optional.
+    pub password: Option<String>,
+    /// The default ttl for put operations.
+    pub default_ttl: Option<Duration>,
+}
+
+/// Config for memory.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MemoryConfig {
+    /// root of the backend.
+    pub root: Option<String>,
+}
+
+/// Config for mini-moka support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MiniMokaConfig {
+    /// Sets the max capacity of the cache.
+    ///
+    /// Refer to [`mini-moka::sync::CacheBuilder::max_capacity`](https://docs.rs/mini-moka/latest/mini_moka/sync/struct.CacheBuilder.html#method.max_capacity)
+    pub max_capacity: Option<u64>,
+    /// Sets the time to live of the cache.
+    ///
+    /// Refer to [`mini-moka::sync::CacheBuilder::time_to_live`](https://docs.rs/mini-moka/latest/mini_moka/sync/struct.CacheBuilder.html#method.time_to_live)
+    pub time_to_live: Option<Duration>,

Review Comment:
   `Duration`'s default serde is weird (things like `{ "secs": 1, "nanos": 0 }`.
   
   It's better to use [`humantime-serde`](https://docs.rs/humantime-serde/latest/humantime_serde/) but that should be a follow up and breaking change.



-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: expose configs always [opendal]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #5034:
URL: https://github.com/apache/opendal/pull/5034#discussion_r1727113800


##########
core/src/services/config.rs:
##########
@@ -0,0 +1,2047 @@
+// 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 serde::{Deserialize, Serialize};
+use std::fmt::{Debug, Formatter};
+use std::time::Duration;
+
+/// Config for Aliyun Drive services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AliyunDriveConfig {
+    /// The Root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// Default to `/` if not set.
+    pub root: Option<String>,
+    /// The access_token of this backend.
+    ///
+    /// Solution for client-only purpose. #4733
+    ///
+    /// Required if no client_id, client_secret and refresh_token are provided.
+    pub access_token: Option<String>,
+    /// The client_id of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub client_id: Option<String>,
+    /// The client_secret of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub client_secret: Option<String>,
+    /// The refresh_token of this backend.
+    ///
+    /// Required if no access_token is provided.
+    pub refresh_token: Option<String>,
+    /// The drive_type of this backend.
+    ///
+    /// All operations will happen under this type of drive.
+    ///
+    /// Available values are `default`, `backup` and `resource`.
+    ///
+    /// Fallback to default if not set or no other drives can be found.
+    pub drive_type: String,
+}
+
+impl Debug for AliyunDriveConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("AliyunDriveConfig");
+
+        d.field("root", &self.root)
+            .field("drive_type", &self.drive_type);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for alluxio services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AlluxioConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// default to `/` if not set.
+    pub root: Option<String>,
+    /// endpoint of this backend.
+    ///
+    /// Endpoint must be full uri, mostly like `http://127.0.0.1:39999`.
+    pub endpoint: Option<String>,
+}
+
+impl Debug for AlluxioConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("AlluxioConfig");
+
+        d.field("root", &self.root)
+            .field("endpoint", &self.endpoint);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for Atomicserver services support
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct AtomicserverConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// private_key of this backend
+    pub private_key: Option<String>,
+    /// public_key of this backend
+    pub public_key: Option<String>,
+    /// parent_resource_id of this backend
+    pub parent_resource_id: Option<String>,
+}
+
+impl Debug for AtomicserverConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("AtomicserverConfig")
+            .field("root", &self.root)
+            .field("endpoint", &self.endpoint)
+            .field("public_key", &self.public_key)
+            .field("parent_resource_id", &self.parent_resource_id)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Azure Storage Blob services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzblobConfig {
+    /// The root of Azblob service backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+
+    /// The container name of Azblob service backend.
+    pub container: String,
+
+    /// The endpoint of Azblob service backend.
+    ///
+    /// Endpoint must be full uri, e.g.
+    ///
+    /// - Azblob: `https://accountname.blob.core.windows.net`
+    /// - Azurite: `http://127.0.0.1:10000/devstoreaccount1`
+    pub endpoint: Option<String>,
+
+    /// The account name of Azblob service backend.
+    pub account_name: Option<String>,
+
+    /// The account key of Azblob service backend.
+    pub account_key: Option<String>,
+
+    /// The encryption key of Azblob service backend.
+    pub encryption_key: Option<String>,
+
+    /// The encryption key sha256 of Azblob service backend.
+    pub encryption_key_sha256: Option<String>,
+
+    /// The encryption algorithm of Azblob service backend.
+    pub encryption_algorithm: Option<String>,
+
+    /// The sas token of Azblob service backend.
+    pub sas_token: Option<String>,
+
+    /// The maximum batch operations of Azblob service backend.
+    pub batch_max_operations: Option<usize>,
+}
+
+impl Debug for AzblobConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzblobConfig");
+
+        ds.field("root", &self.root);
+        ds.field("container", &self.container);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+        if self.sas_token.is_some() {
+            ds.field("sas_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Azure Data Lake Storage Gen2 Support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzdlsConfig {
+    /// Root of this backend.
+    pub root: Option<String>,
+    /// Filesystem name of this backend.
+    pub filesystem: String,
+    /// Endpoint of this backend.
+    pub endpoint: Option<String>,
+    /// Account name of this backend.
+    pub account_name: Option<String>,
+    /// Account key of this backend.
+    pub account_key: Option<String>,
+}
+
+impl Debug for AzdlsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzdlsConfig");
+
+        ds.field("root", &self.root);
+        ds.field("filesystem", &self.filesystem);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Azure File services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct AzfileConfig {
+    /// The root path for azfile.
+    pub root: Option<String>,
+    /// The endpoint for azfile.
+    pub endpoint: Option<String>,
+    /// The share name for azfile.
+    pub share_name: String,
+    /// The account name for azfile.
+    pub account_name: Option<String>,
+    /// The account key for azfile.
+    pub account_key: Option<String>,
+    /// The sas token for azfile.
+    pub sas_token: Option<String>,
+}
+
+impl Debug for AzfileConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("AzfileConfig");
+
+        ds.field("root", &self.root);
+        ds.field("share_name", &self.share_name);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.account_name.is_some() {
+            ds.field("account_name", &"<redacted>");
+        }
+        if self.account_key.is_some() {
+            ds.field("account_key", &"<redacted>");
+        }
+        if self.sas_token.is_some() {
+            ds.field("sas_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for backblaze b2 services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct B2Config {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// keyID of this backend.
+    ///
+    /// - If application_key_id is set, we will take user's input first.
+    /// - If not, we will try to load it from environment.
+    pub application_key_id: Option<String>,
+    /// applicationKey of this backend.
+    ///
+    /// - If application_key is set, we will take user's input first.
+    /// - If not, we will try to load it from environment.
+    pub application_key: Option<String>,
+    /// bucket of this backend.
+    ///
+    /// required.
+    pub bucket: String,
+    /// bucket id of this backend.
+    ///
+    /// required.
+    pub bucket_id: String,
+}
+
+impl Debug for B2Config {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("B2Config");
+
+        d.field("root", &self.root)
+            .field("application_key_id", &self.application_key_id)
+            .field("bucket_id", &self.bucket_id)
+            .field("bucket", &self.bucket);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// cacache service support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CacacheConfig {
+    /// That path to the cacache data directory.
+    pub datadir: Option<String>,
+}
+
+/// Config for Chainsafe services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct ChainsafeConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// api_key of this backend.
+    pub api_key: Option<String>,
+    /// bucket_id of this backend.
+    ///
+    /// required.
+    pub bucket_id: String,
+}
+
+impl Debug for ChainsafeConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("ChainsafeConfig");
+
+        d.field("root", &self.root)
+            .field("bucket_id", &self.bucket_id);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Cloudflare KV Service Support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CloudflareKvConfig {
+    /// The token used to authenticate with CloudFlare.
+    pub token: Option<String>,
+    /// The account ID used to authenticate with CloudFlare. Used as URI path parameter.
+    pub account_id: Option<String>,
+    /// The namespace ID. Used as URI path parameter.
+    pub namespace_id: Option<String>,
+
+    /// Root within this backend.
+    pub root: Option<String>,
+}
+
+impl Debug for CloudflareKvConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("CloudflareKvConfig");
+
+        ds.field("root", &self.root);
+        ds.field("account_id", &self.account_id);
+        ds.field("namespace_id", &self.namespace_id);
+
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// compio-based file system support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct CompfsConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+}
+
+/// Tencent-Cloud COS services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+pub struct CosConfig {
+    /// Root of this backend.
+    pub root: Option<String>,
+    /// Endpoint of this backend.
+    pub endpoint: Option<String>,
+    /// Secret ID of this backend.
+    pub secret_id: Option<String>,
+    /// Secret key of this backend.
+    pub secret_key: Option<String>,
+    /// Bucket of this backend.
+    pub bucket: Option<String>,
+    /// Disable config load so that opendal will not load config from
+    pub disable_config_load: bool,
+}
+
+impl Debug for CosConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("CosConfig")
+            .field("root", &self.root)
+            .field("endpoint", &self.endpoint)
+            .field("secret_id", &"<redacted>")
+            .field("secret_key", &"<redacted>")
+            .field("bucket", &self.bucket)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for [Cloudflare D1](https://developers.cloudflare.com/d1) backend support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct D1Config {
+    /// Set the token of cloudflare api.
+    pub token: Option<String>,
+    /// Set the account id of cloudflare api.
+    pub account_id: Option<String>,
+    /// Set the database id of cloudflare api.
+    pub database_id: Option<String>,
+
+    /// Set the working directory of OpenDAL.
+    pub root: Option<String>,
+    /// Set the table of D1 Database.
+    pub table: Option<String>,
+    /// Set the key field of D1 Database.
+    pub key_field: Option<String>,
+    /// Set the value field of D1 Database.
+    pub value_field: Option<String>,
+}
+
+impl Debug for D1Config {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("D1Config");
+        ds.field("root", &self.root);
+        ds.field("table", &self.table);
+        ds.field("key_field", &self.key_field);
+        ds.field("value_field", &self.value_field);
+        ds.finish_non_exhaustive()
+    }
+}
+
+/// [dashmap](https://github.com/xacrimon/dashmap) backend support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct DashmapConfig {
+    /// The root path for dashmap.
+    pub root: Option<String>,
+}
+
+/// [Dbfs](https://docs.databricks.com/api/azure/workspace/dbfs)'s REST API support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+pub struct DbfsConfig {
+    /// The root for dbfs.
+    pub root: Option<String>,
+    /// The endpoint for dbfs.
+    pub endpoint: Option<String>,
+    /// The token for dbfs.
+    pub token: Option<String>,
+}
+
+impl Debug for DbfsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("DbfsConfig");
+
+        ds.field("root", &self.root);
+        ds.field("endpoint", &self.endpoint);
+
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for [Dropbox](https://www.dropbox.com/) backend support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct DropboxConfig {
+    /// root path for dropbox.
+    pub root: Option<String>,
+    /// access token for dropbox.
+    pub access_token: Option<String>,
+    /// refresh_token for dropbox.
+    pub refresh_token: Option<String>,
+    /// client_id for dropbox.
+    pub client_id: Option<String>,
+    /// client_secret for dropbox.
+    pub client_secret: Option<String>,
+}
+
+impl Debug for DropboxConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("DropBoxConfig")
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for Etcd services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct EtcdConfig {
+    /// network address of the Etcd services.
+    /// If use https, must set TLS options: `ca_path`, `cert_path`, `key_path`.
+    /// e.g. "127.0.0.1:23790,127.0.0.1:23791,127.0.0.1:23792" or "http://127.0.0.1:23790,http://127.0.0.1:23791,http://127.0.0.1:23792" or "https://127.0.0.1:23790,https://127.0.0.1:23791,https://127.0.0.1:23792"
+    ///
+    /// default is "http://127.0.0.1:2379"
+    pub endpoints: Option<String>,
+    /// the username to connect etcd service.
+    ///
+    /// default is None
+    pub username: Option<String>,
+    /// the password for authentication
+    ///
+    /// default is None
+    pub password: Option<String>,
+    /// the working directory of the etcd service. Can be "/path/to/dir"
+    ///
+    /// default is "/"
+    pub root: Option<String>,
+    /// certificate authority file path
+    ///
+    /// default is None
+    pub ca_path: Option<String>,
+    /// cert path
+    ///
+    /// default is None
+    pub cert_path: Option<String>,
+    /// key path
+    ///
+    /// default is None
+    pub key_path: Option<String>,
+}
+
+impl Debug for EtcdConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("EtcdConfig");
+
+        ds.field("root", &self.root);
+        if let Some(endpoints) = self.endpoints.clone() {
+            ds.field("endpoints", &endpoints);
+        }
+        if let Some(username) = self.username.clone() {
+            ds.field("username", &username);
+        }
+        if self.password.is_some() {
+            ds.field("password", &"<redacted>");
+        }
+        if let Some(ca_path) = self.ca_path.clone() {
+            ds.field("ca_path", &ca_path);
+        }
+        if let Some(cert_path) = self.cert_path.clone() {
+            ds.field("cert_path", &cert_path);
+        }
+        if let Some(key_path) = self.key_path.clone() {
+            ds.field("key_path", &key_path);
+        }
+        ds.finish()
+    }
+}
+
+/// [foundationdb](https://www.foundationdb.org/) service support.
+///Config for FoundationDB.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FoundationdbConfig {
+    ///root of the backend.
+    pub root: Option<String>,
+    ///config_path for the backend.
+    pub config_path: Option<String>,
+}
+
+impl Debug for FoundationdbConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("FoundationConfig");
+
+        ds.field("root", &self.root);
+        ds.field("config_path", &self.config_path);
+
+        ds.finish()
+    }
+}
+
+/// config for file system
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FsConfig {
+    /// root dir for backend
+    pub root: Option<String>,
+
+    /// tmp dir for atomic write
+    pub atomic_write_dir: Option<String>,
+}
+
+/// Config for Ftp services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct FtpConfig {
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// root of this backend
+    pub root: Option<String>,
+    /// user of this backend
+    pub user: Option<String>,
+    /// password of this backend
+    pub password: Option<String>,
+}
+
+impl Debug for FtpConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("FtpConfig")
+            .field("endpoint", &self.endpoint)
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// [Google Cloud Storage](https://cloud.google.com/storage) services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GcsConfig {
+    /// root URI, all operations happens under `root`
+    pub root: Option<String>,
+    /// bucket name
+    pub bucket: String,
+    /// endpoint URI of GCS service,
+    /// default is `https://storage.googleapis.com`
+    pub endpoint: Option<String>,
+    /// Scope for gcs.
+    pub scope: Option<String>,
+    /// Service Account for gcs.
+    pub service_account: Option<String>,
+    /// Credentials string for GCS service OAuth2 authentication.
+    pub credential: Option<String>,
+    /// Local path to credentials file for GCS service OAuth2 authentication.
+    pub credential_path: Option<String>,
+    /// The predefined acl for GCS.
+    pub predefined_acl: Option<String>,
+    /// The default storage class used by gcs.
+    pub default_storage_class: Option<String>,
+    /// Allow opendal to send requests without signing when credentials are not
+    /// loaded.
+    pub allow_anonymous: bool,
+    /// Disable attempting to load credentials from the GCE metadata server when
+    /// running within Google Cloud.
+    pub disable_vm_metadata: bool,
+    /// Disable loading configuration from the environment.
+    pub disable_config_load: bool,
+    /// A Google Cloud OAuth2 token.
+    ///
+    /// Takes precedence over `credential` and `credential_path`.
+    pub token: Option<String>,
+}
+
+impl Debug for GcsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GcsConfig")
+            .field("root", &self.root)
+            .field("bucket", &self.bucket)
+            .field("endpoint", &self.endpoint)
+            .field("scope", &self.scope)
+            .finish_non_exhaustive()
+    }
+}
+
+/// [GoogleDrive](https://drive.google.com/) configuration.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GdriveConfig {
+    /// The root for gdrive
+    pub root: Option<String>,
+    /// Access token for gdrive.
+    pub access_token: Option<String>,
+    /// Refresh token for gdrive.
+    pub refresh_token: Option<String>,
+    /// Client id for gdrive.
+    pub client_id: Option<String>,
+    /// Client secret for gdrive.
+    pub client_secret: Option<String>,
+}
+
+impl Debug for GdriveConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GdriveConfig")
+            .field("root", &self.root)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for GitHub Action Cache Services support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GhacConfig {
+    /// The root path for ghac.
+    pub root: Option<String>,
+    /// The version that used by cache.
+    pub version: Option<String>,
+    /// The endpoint for ghac service.
+    pub endpoint: Option<String>,
+    /// The runtime token for ghac service.
+    pub runtime_token: Option<String>,
+}
+
+/// Config for GitHub services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GithubConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// GitHub access_token.
+    ///
+    /// optional.
+    /// If not provided, the backend will only support read operations for public repositories.
+    /// And rate limit will be limited to 60 requests per hour.
+    pub token: Option<String>,
+    /// GitHub repo owner.
+    ///
+    /// required.
+    pub owner: String,
+    /// GitHub repo name.
+    ///
+    /// required.
+    pub repo: String,
+}
+
+impl Debug for GithubConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("GithubConfig");
+
+        d.field("root", &self.root)
+            .field("owner", &self.owner)
+            .field("repo", &self.repo);
+
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for Grid file system support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct GridFsConfig {
+    /// The connection string of the MongoDB service.
+    pub connection_string: Option<String>,
+    /// The database name of the MongoDB GridFs service to read/write.
+    pub database: Option<String>,
+    /// The bucket name of the MongoDB GridFs service to read/write.
+    pub bucket: Option<String>,
+    /// The chunk size of the MongoDB GridFs service used to break the user file into chunks.
+    pub chunk_size: Option<u32>,
+    /// The working directory, all operations will be performed under it.
+    pub root: Option<String>,
+}
+
+impl Debug for GridFsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("GridFsConfig")
+            .field("database", &self.database)
+            .field("bucket", &self.bucket)
+            .field("chunk_size", &self.chunk_size)
+            .field("root", &self.root)
+            .finish()
+    }
+}
+
+/// [Hadoop Distributed File System (HDFS™)](https://hadoop.apache.org/) support.
+///
+/// Config for Hdfs services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HdfsConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// name node of this backend
+    pub name_node: Option<String>,
+    /// kerberos_ticket_cache_path of this backend
+    pub kerberos_ticket_cache_path: Option<String>,
+    /// user of this backend
+    pub user: Option<String>,
+    /// enable the append capacity
+    pub enable_append: bool,
+    /// atomic_write_dir of this backend
+    pub atomic_write_dir: Option<String>,
+}
+
+impl Debug for HdfsConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("HdfsConfig")
+            .field("root", &self.root)
+            .field("name_node", &self.name_node)
+            .field(
+                "kerberos_ticket_cache_path",
+                &self.kerberos_ticket_cache_path,
+            )
+            .field("user", &self.user)
+            .field("enable_append", &self.enable_append)
+            .field("atomic_write_dir", &self.atomic_write_dir)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for HdfsNative services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HdfsNativeConfig {
+    /// work dir of this backend
+    pub root: Option<String>,
+    /// url of this backend
+    pub url: Option<String>,
+    /// enable the append capacity
+    pub enable_append: bool,
+}
+
+impl Debug for HdfsNativeConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        f.debug_struct("HdfsNativeConfig")
+            .field("root", &self.root)
+            .field("url", &self.url)
+            .field("enable_append", &self.enable_append)
+            .finish_non_exhaustive()
+    }
+}
+
+/// Config for Http service support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HttpConfig {
+    /// endpoint of this backend
+    pub endpoint: Option<String>,
+    /// username of this backend
+    pub username: Option<String>,
+    /// password of this backend
+    pub password: Option<String>,
+    /// token of this backend
+    pub token: Option<String>,
+    /// root of this backend
+    pub root: Option<String>,
+}
+
+impl Debug for HttpConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut de = f.debug_struct("HttpConfig");
+        de.field("endpoint", &self.endpoint);
+        de.field("root", &self.root);
+
+        de.finish_non_exhaustive()
+    }
+}
+
+/// Configuration for Huggingface service support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct HuggingfaceConfig {
+    /// Repo type of this backend. Default is model.
+    ///
+    /// Available values:
+    /// - model
+    /// - dataset
+    pub repo_type: Option<String>,
+    /// Repo id of this backend.
+    ///
+    /// This is required.
+    pub repo_id: Option<String>,
+    /// Revision of this backend.
+    ///
+    /// Default is main.
+    pub revision: Option<String>,
+    /// Root of this backend. Can be "/path/to/dir".
+    ///
+    /// Default is "/".
+    pub root: Option<String>,
+    /// Token of this backend.
+    ///
+    /// This is optional.
+    pub token: Option<String>,
+}
+
+impl Debug for HuggingfaceConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("HuggingfaceConfig");
+
+        if let Some(repo_type) = &self.repo_type {
+            ds.field("repo_type", &repo_type);
+        }
+        if let Some(repo_id) = &self.repo_id {
+            ds.field("repo_id", &repo_id);
+        }
+        if let Some(revision) = &self.revision {
+            ds.field("revision", &revision);
+        }
+        if let Some(root) = &self.root {
+            ds.field("root", &root);
+        }
+        if self.token.is_some() {
+            ds.field("token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for icloud services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IcloudConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    ///
+    /// default to `/` if not set.
+    pub root: Option<String>,
+    /// apple_id of this backend.
+    ///
+    /// apple_id must be full, mostly like `example@gmail.com`.
+    pub apple_id: Option<String>,
+    /// password of this backend.
+    ///
+    /// password must be full.
+    pub password: Option<String>,
+
+    /// Session
+    ///
+    /// token must be valid.
+    pub trust_token: Option<String>,
+    /// ds_web_auth_token must be set in Session
+    pub ds_web_auth_token: Option<String>,
+    /// enable the china origin
+    /// China region `origin` Header needs to be set to "https://www.icloud.com.cn".
+    ///
+    /// otherwise Apple server will return 302.
+    pub is_china_mainland: bool,
+}
+
+impl Debug for IcloudConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut d = f.debug_struct("IcloudBuilder");
+        d.field("root", &self.root);
+        d.field("is_china_mainland", &self.is_china_mainland);
+        d.finish_non_exhaustive()
+    }
+}
+
+/// Config for IPFS file system support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IpfsConfig {
+    /// IPFS gateway endpoint.
+    pub endpoint: Option<String>,
+    /// IPFS root.
+    pub root: Option<String>,
+}
+
+/// Config for IPFS MFS support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct IpmfsConfig {
+    /// Root for ipfs.
+    pub root: Option<String>,
+    /// Endpoint for ipfs.
+    pub endpoint: Option<String>,
+}
+
+/// Config for Koofr services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct KoofrConfig {
+    /// root of this backend.
+    ///
+    /// All operations will happen under this root.
+    pub root: Option<String>,
+    /// Koofr endpoint.
+    pub endpoint: String,
+    /// Koofr email.
+    pub email: String,
+    /// password of this backend. (Must be the application password)
+    pub password: Option<String>,
+}
+
+impl Debug for KoofrConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("Config");
+
+        ds.field("root", &self.root);
+        ds.field("email", &self.email);
+
+        ds.finish()
+    }
+}
+
+/// Config for Libsql services support.
+#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct LibsqlConfig {
+    /// Connection string for libsql service.
+    pub connection_string: Option<String>,
+    /// Authentication token for libsql service.
+    pub auth_token: Option<String>,
+
+    /// Table name for libsql service.
+    pub table: Option<String>,
+    /// Key field name for libsql service.
+    pub key_field: Option<String>,
+    /// Value field name for libsql service.
+    pub value_field: Option<String>,
+    /// Root for libsql service.
+    pub root: Option<String>,
+}
+
+impl Debug for LibsqlConfig {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        let mut ds = f.debug_struct("LibsqlConfig");
+        ds.field("connection_string", &self.connection_string)
+            .field("table", &self.table)
+            .field("key_field", &self.key_field)
+            .field("value_field", &self.value_field)
+            .field("root", &self.root);
+
+        if self.auth_token.is_some() {
+            ds.field("auth_token", &"<redacted>");
+        }
+
+        ds.finish()
+    }
+}
+
+/// Config for MemCached services support
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MemcachedConfig {
+    /// network address of the memcached service.
+    ///
+    /// For example: "tcp://localhost:11211"
+    pub endpoint: Option<String>,
+    /// the working directory of the service. Can be "/path/to/dir"
+    ///
+    /// default is "/"
+    pub root: Option<String>,
+    /// Memcached username, optional.
+    pub username: Option<String>,
+    /// Memcached password, optional.
+    pub password: Option<String>,
+    /// The default ttl for put operations.
+    pub default_ttl: Option<Duration>,
+}
+
+/// Config for memory.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MemoryConfig {
+    /// root of the backend.
+    pub root: Option<String>,
+}
+
+/// Config for mini-moka support.
+#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct MiniMokaConfig {
+    /// Sets the max capacity of the cache.
+    ///
+    /// Refer to [`mini-moka::sync::CacheBuilder::max_capacity`](https://docs.rs/mini-moka/latest/mini_moka/sync/struct.CacheBuilder.html#method.max_capacity)
+    pub max_capacity: Option<u64>,
+    /// Sets the time to live of the cache.
+    ///
+    /// Refer to [`mini-moka::sync::CacheBuilder::time_to_live`](https://docs.rs/mini-moka/latest/mini_moka/sync/struct.CacheBuilder.html#method.time_to_live)
+    pub time_to_live: Option<Duration>,

Review Comment:
   Somehow reasonable. In milliseconds precison?



-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(core): expose configs always [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #5034:
URL: https://github.com/apache/opendal/pull/5034#issuecomment-2306621038

   cc @tisonkun, please take a look.
   
   I prefer to have them in separate files for better readability and easier future code generation.


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(core): expose configs always [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #5034:
URL: https://github.com/apache/opendal/pull/5034


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: expose configs always [opendal]

Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #5034:
URL: https://github.com/apache/opendal/pull/5034#issuecomment-2304745549

   > Overall, this idea looks good to me. However, placing it in `services/mod.rs` might be difficult to maintain.
   > 
   > Do you think it would be better to have `s3_config.rs`?
   
   I move them to `core/services/config.rs`, not `mod.rs`.
   
   Each struct is tidy and no more extension can be added. So split to many files (`core/services/config/s3.rs` in this case) seems only extra burden without certain benefits.


-- 
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: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org