pub struct AsyncClient<S = TcpStream> { /* private fields */ }Expand description
Asynchronous ClickHouse native protocol client.
Client accepts any AsyncTransport. connect creates a
TCP connection. connect_tls creates a rustls
connection when tls feature is enabled. boxed erases
transport type.
Implementations§
Source§impl AsyncClient<TcpStream>
impl AsyncClient<TcpStream>
Sourcepub async fn connect<A>(
addr: A,
opts: ClientOpts,
codec: Option<Pin<Box<Codec>>>,
) -> Result<Self>where
A: ToSocketAddrs,
pub async fn connect<A>(
addr: A,
opts: ClientOpts,
codec: Option<Pin<Box<Codec>>>,
) -> Result<Self>where
A: ToSocketAddrs,
Connects over TCP and completes Hello handshake.
Socket uses TCP_NODELAY.
Source§impl AsyncClient<TlsStream<TcpStream>>
impl AsyncClient<TlsStream<TcpStream>>
Sourcepub async fn connect_tls<A>(
addr: A,
domain: &str,
opts: ClientOpts,
codec: Option<Pin<Box<Codec>>>,
config: Arc<ClientConfig>,
) -> Result<Self>where
A: ToSocketAddrs,
pub async fn connect_tls<A>(
addr: A,
domain: &str,
opts: ClientOpts,
codec: Option<Pin<Box<Codec>>>,
config: Arc<ClientConfig>,
) -> Result<Self>where
A: ToSocketAddrs,
Connects over TCP and TLS, then completes Hello handshake.
TLS verifies peer using config and domain. Domain is also sent as
SNI. Default configuration is available from
tls::default_config.
Source§impl<S: AsyncTransport> AsyncClient<S>
impl<S: AsyncTransport> AsyncClient<S>
Sourcepub async fn handshake_on(
stream: S,
opts: ClientOpts,
codec: Option<Pin<Box<Codec>>>,
) -> Result<Self>
pub async fn handshake_on( stream: S, opts: ClientOpts, codec: Option<Pin<Box<Codec>>>, ) -> Result<Self>
Completes Hello handshake over an existing transport.
pub async fn send_query( &mut self, sql: &str, query_id: Option<&str>, ) -> Result<()>
Sourcepub async fn send_data(
&mut self,
builder: Option<&BlockBuilder<'_>>,
) -> Result<()>
pub async fn send_data( &mut self, builder: Option<&BlockBuilder<'_>>, ) -> Result<()>
Sends a Data block, or empty terminator when builder is None.
Sourcepub async fn send_data_end(&mut self) -> Result<()>
pub async fn send_data_end(&mut self) -> Result<()>
Sends empty Data block that ends INSERT input.
Sourcepub async fn recv_event(&mut self) -> Result<Event>
pub async fn recv_event(&mut self) -> Result<Event>
Waits for next server event.
Returned event owns block or exception payload.
Sourcepub fn server_info(&self) -> Option<ServerInfo>
pub fn server_info(&self) -> Option<ServerInfo>
Returns server identity received during handshake.
Sourcepub fn boxed(self) -> BoxedAsyncClientwhere
S: 'static,
pub fn boxed(self) -> BoxedAsyncClientwhere
S: 'static,
Erases transport type without changing connection state.
Sourcepub fn core(&mut self) -> &mut IolessClient
pub fn core(&mut self) -> &mut IolessClient
Returns mutable access to transport-independent protocol client.