wjones127 commented on code in PR #416: URL: https://github.com/apache/arrow-adbc/pull/416#discussion_r1116256418
########## rust/src/driver_manager.rs: ########## @@ -0,0 +1,892 @@ +// 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. + +//! Load and use ADBC drivers. +//! +//! ## Loading a driver +//! +//! Drivers are initialized using a function provided by the driver as a main +//! entrypoint, canonically called `AdbcDriverInit`. (Although many will use a +//! different name to support statically linking multiple drivers within the +//! same program.) +//! +//! To load from a function, use [AdbcDriver::load_from_init]. +//! +//! To load from a dynamic library, use [AdbcDriver::load]. +//! +//! ## Using across threads +//! +//! [AdbcDriver] and [AdbcDatabase] can be used across multiple threads. They +//! hold their inner implementations within [std::sync::Arc], so they are +//! cheaply copy-able. +//! +//! [AdbcConnection] should not be used across multiple threads. Driver +//! implementations do not guarantee connection APIs are safe to call from +//! multiple threads, unless calls are carefully sequenced. So instead of using +//! the same connection across multiple threads, create a connection for each +//! thread. [AdbcConnectionBuilder] is [core::marker::Send], so it can be moved +//! to a new thread before initialized into an [AdbcConnection]. [AdbcConnection] +//! holds it's inner data in a [std::rc::Rc], so it is also cheaply copyable. Review Comment: FWIW the Rust model is described well here: https://rust-lang.github.io/async-book/02_execution/02_future.html. But for now I was simply thinking that Rust driver manager could wrap the blocking calls into C drivers with [tokio::spawn_blocking()](https://docs.rs/tokio/latest/tokio/task/fn.spawn_blocking.html), which sends the call to another thread to execute. This is what Rust async libraries do for filesystem interaction on systems that don't provide a native async interface. And then native Rust drivers could always be async. But maybe there is value in having both async and blocking versions of `execute()` in the Rust API. Something I'll try to get feedback from the Rust community on once I have a proposal for the ADBC Rust API. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org