G-XD commented on code in PR #3233: URL: https://github.com/apache/incubator-opendal/pull/3233#discussion_r1349737944
########## core/src/services/libsql/backend.rs: ########## @@ -0,0 +1,345 @@ +// 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 std::collections::HashMap; +use std::fmt::Debug; + +use async_trait::async_trait; +use libsql_client::{args, Config, Statement, SyncClient, Value}; Review Comment: > You can wrap a `Arc<Mutex<T>>` for it. Hi @Xuanwo, I tried it and still got the same error after using the Arc<Mutex< Client >>. <details> <summary>msg</summary> ```plaintext error: future cannot be sent between threads safely --> core/src/services/libsql/backend.rs:310:65 | 310 | async fn set(&self, path: &str, value: &[u8]) -> Result<()> { | _________________________________________________________________^ 311 | | let query = format!( 312 | | "INSERT OR REPLACE INTO `{}` (`{}`, `{}`) VALUES (?, ?)", 313 | | self.table, self.key_field, self.value_field ... | 323 | | Ok(()) 324 | | } | |_____^ future created by async block is not `Send` | = help: within `libsql_client::Client`, the trait `Sync` is not implemented for `*mut libsql_sys::ffi::sqlite3` note: future is not `Send` as this value is used across an await --> core/src/services/libsql/backend.rs:321:13 | 319 | client.lock().await | ------------------- has type `&libsql_client::Client` which is not `Send` 320 | .execute(Statement::with_args(query, args!(path, value.to_vec()))) 321 | .await | ^^^^^^ await occurs here, with `client.lock().await` maybe used later 322 | .map_err(|err| parse_error_msg(err, "set failed"))?; | - `client.lock().await` is later dropped here help: consider moving this into a `let` binding to create a shorter lived borrow --> core/src/services/libsql/backend.rs:319:9 | 319 | / client.lock().await 320 | | .execute(Statement::with_args(query, args!(path, value.to_vec()))) | |______________________________________________________________________________^ = note: required for the cast from `[async block@core/src/services/libsql/backend.rs:310:65: 324:6]` to the object type `dyn futures::Future<Output = std::result::Result<(), types::error::Error>> + std::marker::Send` ``` </details> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
