Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }
Expand description

A connection to ClickHouse with health status tracking.

This wrapper around clickhouse::Client adds tracking of whether the connection is still valid. It implements Deref and DerefMut so it can be used transparently like a clickhouse::Client.

Implementations§

Source§

impl Connection

Source

pub fn is_broken(&self) -> bool

Checks if the connection is broken.

Methods from Deref<Target = Client>§

Source

pub async fn insert<T>(&self, table: &str) -> Result<Insert<T>, Error>
where T: Row,

Starts a new INSERT statement.

§Validation

If validation is enabled (default), RowBinaryWithNamesAndTypes input format is used. When Client::insert method is called for this table for the first time, it will fetch the table schema from the server, allowing to validate the serialized rows, as well as write the names and types of the columns in the request header.

Fetching the schema will happen only once per table, as the schema is cached by the client internally.

With disabled validation, the schema is not fetched, and the rows serialized with RowBinary input format.

§Panics

If T has unnamed fields, e.g. tuples.

Source

pub fn query(&self, query: &str) -> Query

Starts a new SELECT/DDL query.

Source

pub async fn clear_cached_metadata(&self)

Clear table metadata that was previously received and cached.

Insert uses cached metadata when sending data with validation. If the table schema changes, this metadata needs to re-fetched.

This method clears the metadata cache, causing future insert queries to re-fetch metadata. This applies to all cloned instances of this Client (using the same URL and database) as well.

This may need to wait to acquire a lock if a query is concurrently writing into the cache.

Cancel-safe.

Trait Implementations§

Source§

impl Deref for Connection

Source§

type Target = Client

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Connection

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Is for T
where T: ?Sized,

Source§

type EqTo = T

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more