pub struct DuckDbConnection { /* private fields */ }Expand description
DuckDB 连接包装器
v0.3.0 性能优化:使用连接池(Vec<duckdb::Connection>)替代单 Mutex<Connection>。
通过 Connection::try_clone() 创建多个连接共享同一个 DatabaseHandle,
每个 spawn_blocking 任务从池中获取一个连接,执行后归还。
Semaphore 限制并发数 = 连接池大小,实现真正的并行查询。
Implementations§
Source§impl DuckDbConnection
impl DuckDbConnection
Sourcepub async fn execute(&self, sql: &str) -> DbResult<DuckDbExecResult>
pub async fn execute(&self, sql: &str) -> DbResult<DuckDbExecResult>
执行 SQL(DDL/DML),返回受影响行数
v0.3.0 连接池模式:从池中取出连接 → spawn_blocking 执行 → 归还连接
Sourcepub async fn query(&self, sql: &str) -> DbResult<Vec<DuckDbRow>>
pub async fn query(&self, sql: &str) -> DbResult<Vec<DuckDbRow>>
执行查询,返回结果行集合
v0.3.0 连接池模式:从池中取出连接 → spawn_blocking 执行 → 归还连接
Sourcepub async fn health_check(&self) -> DbResult<()>
pub async fn health_check(&self) -> DbResult<()>
Trait Implementations§
Source§impl Clone for DuckDbConnection
impl Clone for DuckDbConnection
Source§fn clone(&self) -> DuckDbConnection
fn clone(&self) -> DuckDbConnection
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for DuckDbConnection
impl !UnwindSafe for DuckDbConnection
impl Freeze for DuckDbConnection
impl Send for DuckDbConnection
impl Sync for DuckDbConnection
impl Unpin for DuckDbConnection
impl UnsafeUnpin for DuckDbConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request