Skip to main content

AsyncClient

Struct AsyncClient 

Source
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>

Source

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>>

Source

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>

Source

pub async fn handshake_on( stream: S, opts: ClientOpts, codec: Option<Pin<Box<Codec>>>, ) -> Result<Self>

Completes Hello handshake over an existing transport.

Source

pub async fn send_query( &mut self, sql: &str, query_id: Option<&str>, ) -> Result<()>

Source

pub async fn send_data( &mut self, builder: Option<&BlockBuilder<'_>>, ) -> Result<()>

Sends a Data block, or empty terminator when builder is None.

Source

pub async fn send_data_end(&mut self) -> Result<()>

Sends empty Data block that ends INSERT input.

Source

pub async fn recv_event(&mut self) -> Result<Event>

Waits for next server event.

Returned event owns block or exception payload.

Source

pub fn server_info(&self) -> Option<ServerInfo>

Returns server identity received during handshake.

Source

pub fn boxed(self) -> BoxedAsyncClient
where S: 'static,

Erases transport type without changing connection state.

Source

pub fn core(&mut self) -> &mut IolessClient

Returns mutable access to transport-independent protocol client.

Auto Trait Implementations§

§

impl<S = TcpStream> !Sync for AsyncClient<S>

§

impl<S> Freeze for AsyncClient<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for AsyncClient<S>
where S: RefUnwindSafe,

§

impl<S> Send for AsyncClient<S>
where S: Send,

§

impl<S> Unpin for AsyncClient<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for AsyncClient<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for AsyncClient<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.