edgedb_client/pool.rs
1use std::sync::Arc;
2
3use async_std::channel::{Sender};
4use async_std::task::JoinHandle;
5use async_std::sync::Mutex;
6
7mod command;
8mod connection;
9mod implementation;
10mod main;
11
12use command::Command;
13use connection::PoolConn;
14use main::PoolState;
15
16
17#[derive(Debug, Clone)]
18struct Options {
19}
20
21#[derive(Debug)]
22/// This structure is shared between Pool instances when options are changed.
23pub(crate) struct PoolInner {
24 chan: Sender<Command>,
25 task: Mutex<Option<JoinHandle<()>>>,
26 state: Arc<PoolState>,
27}
28
29/// A database connection client.
30///
31/// This is the struct used to interact with the database. Typically, you will
32/// use the [`connect()`](crate::connect) function to create this struct, or
33/// with a [`Builder`](crate::Builder) that you pass to
34/// [`Client::new()`](crate::Client::new).
35///
36// User-visible instance of connection pool. Shallowly clonable contains
37// options (clone pool to modify options). All the functionality is actually
38// in the `PoolInner`
39#[derive(Debug, Clone)]
40pub struct Client {
41 #[allow(dead_code)] // TODO
42 options: Arc<Options>,
43 pub(crate) inner: Arc<PoolInner>,
44}