Skip to content

Commit

Permalink
refactor: use sqlx for sql services (#5040)
Browse files Browse the repository at this point in the history
* refactor: use sqlx for sql services

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

* migrate postgresql services

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

* migrate mysql services

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

* migrate sqlite services

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

* fixup

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

* docs

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

* fixup build by revert

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

* clippy

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

* f tokio runtime

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

* build bindings

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

* tidy

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

* fixup

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

* Update cargo.lock

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

---------

Signed-off-by: tison <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
Co-authored-by: Xuanwo <[email protected]>
  • Loading branch information
tisonkun and Xuanwo authored Aug 26, 2024
1 parent 74a3e29 commit 69ed149
Show file tree
Hide file tree
Showing 20 changed files with 559 additions and 921 deletions.
4 changes: 2 additions & 2 deletions bindings/c/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn build_operator(
schema: core::Scheme,
map: HashMap<String, String>,
) -> core::Result<core::Operator> {
let mut op = match core::Operator::via_map(schema, map) {
let mut op = match core::Operator::via_iter(schema, map) {
Ok(o) => o,
Err(e) => return Err(e),
};
Expand Down Expand Up @@ -173,7 +173,7 @@ pub unsafe extern "C" fn opendal_operator_new(
}
};

let mut map = HashMap::default();
let mut map = HashMap::<String, String>::default();
if !options.is_null() {
for (k, v) in (*options).as_ref() {
map.insert(k.to_string(), v.to_string());
Expand Down
5 changes: 3 additions & 2 deletions bindings/cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod lister;
mod reader;
mod types;

use std::collections::HashMap;
use std::str::FromStr;

use anyhow::Result;
Expand Down Expand Up @@ -101,12 +102,12 @@ pub struct Operator(od::BlockingOperator);
fn new_operator(scheme: &str, configs: Vec<ffi::HashMapValue>) -> Result<Box<Operator>> {
let scheme = od::Scheme::from_str(scheme)?;

let map = configs
let map: HashMap<String, String> = configs
.into_iter()
.map(|value| (value.key, value.value))
.collect();

let op = Box::new(Operator(od::Operator::via_map(scheme, map)?.blocking()));
let op = Box::new(Operator(od::Operator::via_iter(scheme, map)?.blocking()));

Ok(op)
}
Expand Down
4 changes: 2 additions & 2 deletions bindings/dotnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pub unsafe extern "C" fn blocking_operator_construct(
Err(_) => return std::ptr::null(),
};

let mut map = HashMap::default();
let mut map = HashMap::<String, String>::default();
map.insert("root".to_string(), "/tmp".to_string());
let op = match opendal::Operator::via_map(scheme, map) {
let op = match opendal::Operator::via_iter(scheme, map) {
Ok(op) => op.blocking(),
Err(err) => {
println!("err={err:?}");
Expand Down
2 changes: 1 addition & 1 deletion bindings/haskell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub unsafe extern "C" fn via_map_ffi(
}
}

let res = match od::Operator::via_map(scheme, map) {
let res = match od::Operator::via_iter(scheme, map) {
Ok(mut operator) => {
operator = operator.layer(RetryLayer::new());
if callback.is_some() {
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/src/async_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn intern_constructor(
) -> Result<jlong> {
let scheme = Scheme::from_str(jstring_to_string(env, &scheme)?.as_str())?;
let map = jmap_to_hashmap(env, &map)?;
let mut op = Operator::via_map(scheme, map)?;
let mut op = Operator::via_iter(scheme, map)?;
if !op.info().full_capability().blocking {
let layer = executor_or_default(env, executor)?.enter_with(BlockingLayer::create)?;
op = op.layer(layer);
Expand Down
4 changes: 2 additions & 2 deletions bindings/lua/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn operator_new<'a>(
return Err(LuaError::external("schema is empty"));
}

let mut map = HashMap::default();
let mut map = HashMap::<String, String>::default();
for pair in option.pairs::<String, String>() {
let (key, value) = pair?;
map.insert(key, value);
Expand All @@ -55,7 +55,7 @@ fn operator_new<'a>(
Err(e) => return Err(LuaError::external(e)),
};

let op = match od::Operator::via_map(od_schema, map) {
let op = match od::Operator::via_iter(od_schema, map) {
Ok(o) => o.blocking(),
Err(e) => return Err(LuaError::external(e)),
};
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Operator {
.map_err(format_napi_error)?;
let options = options.unwrap_or_default();

let mut op = opendal::Operator::via_map(scheme, options).map_err(format_napi_error)?;
let mut op = opendal::Operator::via_iter(scheme, options).map_err(format_napi_error)?;

if !op.info().full_capability().blocking {
if let Ok(handle) = tokio::runtime::Handle::try_current() {
Expand Down
2 changes: 1 addition & 1 deletion bindings/ocaml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn new_operator(
) -> Result<od::Operator, od::Error> {
let hm: HashMap<String, String> = map.into_iter().collect();
let scheme: od::Scheme = od::Scheme::from_str(&scheme_str)?;
od::Operator::via_map(scheme, hm)
od::Operator::via_iter(scheme, hm)
}

pub fn map_res_error<T>(res: Result<T, od::Error>) -> Result<T, String> {
Expand Down
2 changes: 1 addition & 1 deletion bindings/php/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Operator(od::BlockingOperator);
impl Operator {
pub fn __construct(scheme_str: String, config: HashMap<String, String>) -> PhpResult<Self> {
let scheme = od::Scheme::from_str(&scheme_str).map_err(format_php_err)?;
let op = od::Operator::via_map(scheme, config).map_err(format_php_err)?;
let op = od::Operator::via_iter(scheme, config).map_err(format_php_err)?;

Ok(Operator(op.blocking()))
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/ruby/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Operator {
.map_err(format_magnus_error)?;
let options = options.unwrap_or_default();

let op = od::Operator::via_map(scheme, options)
let op = od::Operator::via_iter(scheme, options)
.map_err(format_magnus_error)?
.blocking();
Ok(Operator(op))
Expand Down
Loading

0 comments on commit 69ed149

Please sign in to comment.