Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make oli support more services #1717

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions bin/oli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ name = "oli"
repository = "https://github.com/apache/incubator-opendal"
version = "0.30.3"

[features]
# Enable services dashmap support
services-dashmap = ["opendal/services-dashmap"]
# Enable services ftp support
services-ftp = ["opendal/services-ftp"]
# Enable services hdfs support
services-hdfs = ["opendal/services-hdfs"]
# Enable services ipfs support
services-ipfs = ["opendal/services-ipfs"]
# Enable services memcached support
services-memcached = ["opendal/services-memcached"]
# Enable services moka support
services-moka = ["opendal/services-moka"]
# Enable services redis support
services-redis = ["opendal/services-redis"]
# Enable services rocksdb support
services-rocksdb = ["opendal/services-rocksdb"]
# Enable services sled support
services-sled = ["opendal/services-sled"]

[dependencies]
anyhow = "1"
clap = { version = "4", features = ["cargo", "string"] }
Expand Down
86 changes: 84 additions & 2 deletions bin/oli/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,96 @@ impl Config {
.ok_or_else(|| anyhow!("missing 'type' in profile"))?;
let scheme = Scheme::from_str(svc)?;
match scheme {
Scheme::S3 => Ok((
Operator::from_map::<services::S3>(profile.clone())?.finish(),
Scheme::Azblob => Ok((
Operator::from_map::<services::Azblob>(profile.clone())?.finish(),
path,
)),
Scheme::Azdfs => Ok((
Operator::from_map::<services::Azdfs>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-dashmap")]
Scheme::Dashmap => Ok((
Operator::from_map::<services::Dashmap>(profile.clone())?.finish(),
path,
)),
Scheme::Gcs => Ok((
Operator::from_map::<services::Gcs>(profile.clone())?.finish(),
path,
)),
Scheme::Ghac => Ok((
Operator::from_map::<services::Ghac>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-hdfs")]
Scheme::Hdfs => Ok((
Operator::from_map::<services::Hdfs>(profile.clone())?.finish(),
path,
)),
Scheme::Http => Ok((
Operator::from_map::<services::Http>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-ftp")]
Scheme::Ftp => Ok((
Operator::from_map::<services::Ftp>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-ipfs")]
Scheme::Ipfs => Ok((
Operator::from_map::<services::Ipfs>(profile.clone())?.finish(),
path,
)),
Scheme::Ipmfs => Ok((
Operator::from_map::<services::Ipmfs>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-memcached")]
Scheme::Memcached => Ok((
Operator::from_map::<services::Memcached>(profile.clone())?.finish(),
path,
)),
// ignore the memory backend
#[cfg(feature = "services-moka")]
Scheme::Moka => Ok((
Operator::from_map::<services::Moka>(profile.clone())?.finish(),
path,
)),
Scheme::Obs => Ok((
Operator::from_map::<services::Obs>(profile.clone())?.finish(),
path,
)),
Scheme::Oss => Ok((
Operator::from_map::<services::Oss>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-redis")]
Scheme::Redis => Ok((
Operator::from_map::<services::Redis>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-rocksdb")]
Scheme::Rocksdb => Ok((
Operator::from_map::<services::Rocksdb>(profile.clone())?.finish(),
path,
)),
Scheme::S3 => Ok((
Operator::from_map::<services::S3>(profile.clone())?.finish(),
path,
)),
#[cfg(feature = "services-sled")]
Scheme::Sled => Ok((
Operator::from_map::<services::Sled>(profile.clone())?.finish(),
path,
)),
Scheme::Webdav => Ok((
Operator::from_map::<services::Webdav>(profile.clone())?.finish(),
path,
)),
Scheme::Webhdfs => Ok((
Operator::from_map::<services::Webhdfs>(profile.clone())?.finish(),
path,
)),
_ => Err(anyhow!("invalid profile")),
}
}
Expand Down