Skip to content

Commit

Permalink
feat: Implement RFC-0501 New Builder (#510)
Browse files Browse the repository at this point in the history
* Save work

Signed-off-by: Xuanwo <[email protected]>

* Save work

Signed-off-by: Xuanwo <[email protected]>

* Save work

Signed-off-by: Xuanwo <[email protected]>

* Save work

Signed-off-by: Xuanwo <[email protected]>

* Save work

Signed-off-by: Xuanwo <[email protected]>

* Fix build

Signed-off-by: Xuanwo <[email protected]>

* Fix build

Signed-off-by: Xuanwo <[email protected]>

* Make clippy happy

Signed-off-by: Xuanwo <[email protected]>

* Make clippy happy

Signed-off-by: Xuanwo <[email protected]>

* Fix unused

Signed-off-by: Xuanwo <[email protected]>

* Remove depends on hyper-tls

Signed-off-by: Xuanwo <[email protected]>

* oay: Fix build

Signed-off-by: Xuanwo <[email protected]>

* Fix unit tests

Signed-off-by: Xuanwo <[email protected]>

* Don't scan everyday

Signed-off-by: Xuanwo <[email protected]>

* Fix tests

Signed-off-by: Xuanwo <[email protected]>

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Aug 11, 2022
1 parent 665557f commit 4f26b73
Show file tree
Hide file tree
Showing 42 changed files with 786 additions and 579 deletions.
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"

# Maintain dependencies for opendal
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"

# Maintain dependencies for oay
- package-ecosystem: "cargo"
directory: "/oay"
schedule:
interval: "daily"
interval: "monthly"

# Maintain dependencies for oli
- package-ecosystem: "cargo"
directory: "/oli"
schedule:
interval: "daily"
interval: "monthly"
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ criterion = { version = "0.3", features = [
] }
dotenv = "0.15"
env_logger = "0.9"
hyper-tls = "0.5"
itertools = "0.10"
num-traits = "0.2"
paste = "1.0"
Expand Down
4 changes: 1 addition & 3 deletions benches/ops/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ async fn service(scheme: Scheme) -> Option<Operator> {
if let Ok(test) = env::var(test_key) {
if test == "on" {
Some(
Operator::from_env(scheme)
.await
.unwrap_or_else(|_| panic!("init {scheme} must succeed")),
Operator::from_env(scheme).unwrap_or_else(|_| panic!("init {scheme} must succeed")),
)
} else {
None
Expand Down
8 changes: 2 additions & 6 deletions examples/azblob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
//! Example for initiating a azblob backend.
use std::env;
use std::sync::Arc;

use anyhow::Result;
use log::info;
use opendal::services::azblob;
use opendal::services::azblob::Builder;
use opendal::Accessor;
use opendal::Operator;

#[tokio::main]
Expand All @@ -46,7 +44,7 @@ Available Environment Values:
);

// Create fs backend builder.
let mut builder: Builder = azblob::Backend::build();
let mut builder: Builder = azblob::Builder::default();
// Set the root, all operations will happen under this root.
//
// NOTE: the root must be absolute path.
Expand All @@ -72,11 +70,9 @@ Available Environment Values:
&env::var("OPENDAL_AZBLOB_ACCOUNT_KEY")
.unwrap_or_else(|_| "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==".to_string()),
);
// Build the `Accessor`.
let accessor: Arc<dyn Accessor> = builder.finish().await?;

// `Accessor` provides the low level APIs, we will use `Operator` normally.
let op: Operator = Operator::new(accessor);
let op: Operator = Operator::new(builder.build()?);

let path = uuid::Uuid::new_v4().to_string();

Expand Down
10 changes: 3 additions & 7 deletions examples/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
//! Example for initiating a fs backend.
use std::env;
use std::sync::Arc;

use anyhow::Result;
use log::info;
use opendal::services::fs;
use opendal::services::fs::Builder;
use opendal::Accessor;
use opendal::Operator;

#[tokio::main]
Expand All @@ -41,16 +39,14 @@ Available Environment Values:
);

// Create fs backend builder.
let mut builder: Builder = fs::Backend::build();
let mut builder: Builder = fs::Builder::default();
// Set the root for fs, all operations will happen under this root.
//
// NOTE: the root must be absolute path.
builder.root(&env::var("OPENDAL_FS_ROOT").unwrap_or_else(|_| "/tmp".to_string()));
// Build the `Accessor`.
let accessor: Arc<dyn Accessor> = builder.finish().await?;

// `Accessor` provides the low level APIs, we will use `Operator` normally.
let op: Operator = Operator::new(accessor);
// Use `Operator` normally.
let op: Operator = Operator::new(builder.build()?);

let path = uuid::Uuid::new_v4().to_string();

Expand Down
8 changes: 2 additions & 6 deletions examples/hdfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
//! Example for initiating a fs backend.
use std::env;
use std::sync::Arc;

use anyhow::Result;
use log::info;
use opendal::services::hdfs;
use opendal::services::hdfs::Builder;
use opendal::Accessor;
use opendal::Operator;

#[tokio::main]
Expand All @@ -41,7 +39,7 @@ Available Environment Values:
);

// Create fs backend builder.
let mut builder: Builder = hdfs::Backend::build();
let mut builder: Builder = hdfs::Builder::default();
// Set the root for hdfs, all operations will happen under this root.
//
// NOTE: the root must be absolute path.
Expand All @@ -51,11 +49,9 @@ Available Environment Values:
// Use `default` as default value.
builder
.name_node(&env::var("OPENDAL_HDFS_NAME_NODE").unwrap_or_else(|_| "default".to_string()));
// Build the `Accessor`.
let accessor: Arc<dyn Accessor> = builder.finish().await?;

// `Accessor` provides the low level APIs, we will use `Operator` normally.
let op: Operator = Operator::new(accessor);
let op: Operator = Operator::new(builder.build()?);

let path = uuid::Uuid::new_v4().to_string();

Expand Down
8 changes: 3 additions & 5 deletions examples/s3-sse-c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
let mut builder: Builder = s3::Backend::build();
let mut builder: Builder = s3::Builder::default();

// Setup builders

// Enable SSE-C
builder.server_side_encryption_with_customer_key("AES256", "customer_key".as_bytes());

let acc = builder.finish().await?;
info!("accessor: {:?}", acc);

let _ = Operator::new(builder.finish().await?);
let op = Operator::new(builder.build()?);
info!("operator: {:?}", op);

// Writing your testing code here.

Expand Down
8 changes: 3 additions & 5 deletions examples/s3-sse-kms-aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
let mut builder: Builder = s3::Backend::build();
let mut builder: Builder = s3::Builder::default();

// Setup builders

// Enable SSE-KMS with aws managed kms key
builder.server_side_encryption_with_aws_managed_kms_key();

let acc = builder.finish().await?;
info!("accessor: {:?}", acc);

let _ = Operator::new(builder.finish().await?);
let op = Operator::new(builder.build()?);
info!("operator: {:?}", op);

// Writing your testing code here.

Expand Down
8 changes: 3 additions & 5 deletions examples/s3-sse-kms-customer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
let mut builder: Builder = s3::Backend::build();
let mut builder: Builder = s3::Builder::default();

// Setup builders

// Enable SSE-KMS with customer managed kms key
builder.server_side_encryption_with_customer_managed_kms_key("aws_kms_key_id");

let acc = builder.finish().await?;
info!("accessor: {:?}", acc);

let _ = Operator::new(builder.finish().await?);
let op = Operator::new(builder.build()?);
info!("operator: {:?}", op);

// Writing your testing code here.

Expand Down
8 changes: 3 additions & 5 deletions examples/s3-sse-s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
let mut builder: Builder = s3::Backend::build();
let mut builder: Builder = s3::Builder::default();

// Setup builders

// Enable SSE-S3
builder.server_side_encryption_with_s3_key();

let acc = builder.finish().await?;
info!("accessor: {:?}", acc);

let _ = Operator::new(builder.finish().await?);
let op = Operator::new(builder.build()?);
info!("operator: {:?}", op);

// Writing your testing code here.

Expand Down
9 changes: 3 additions & 6 deletions examples/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

//! Example for initiating a s3 backend.
use std::env;
use std::sync::Arc;

use anyhow::Result;
use log::info;
use opendal::services::s3;
use opendal::services::s3::Builder;
use opendal::Accessor;
use opendal::Operator;

#[tokio::main]
Expand All @@ -45,7 +43,7 @@ Available Environment Values:
);

// Create s3 backend builder.
let mut builder: Builder = s3::Backend::build();
let mut builder: Builder = s3::Builder::default();
// Set the root for s3, all operations will happen under this root.
//
// NOTE: the root must be absolute path.
Expand Down Expand Up @@ -80,11 +78,10 @@ Available Environment Values:
&env::var("OPENDAL_S3_SECRET_ACCESS_KEY")
.expect("env OPENDAL_S3_SECRET_ACCESS_KEY not set"),
);
// Build the `Accessor`.
let accessor: Arc<dyn Accessor> = builder.finish().await?;

// `Accessor` provides the low level APIs, we will use `Operator` normally.
let op: Operator = Operator::new(accessor);
let op: Operator = Operator::new(builder.build()?);
info!("operator: {:?}", op);

let path = uuid::Uuid::new_v4().to_string();

Expand Down
58 changes: 0 additions & 58 deletions oay/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion oay/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub async fn get_oay_operator() -> Result<Operator> {
.map(|k| (k.to_string(), v))
});

let op = Operator::from_iter(scheme, envs).await?;
let op = Operator::from_iter(scheme, envs)?;

Ok(op)
}
Loading

1 comment on commit 4f26b73

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for opendal ready!

✅ Preview
https://opendal-az5iapenu-databend.vercel.app

Built with commit 4f26b73.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.