proton_client/mod.rs
1mod alias;
2mod default;
3mod display;
4mod error;
5mod fetch;
6mod getters;
7mod insert;
8pub mod prelude;
9mod query;
10mod stream;
11
12use clickhouse::{Client, Compression};
13
14#[derive(Clone)]
15pub struct ProtonClient {
16 client: Client,
17 // A separate client without compression is currently necessary to enable
18 // streaming queries in release builds. See issue #6 on Github:
19 // https://github.com/timeplus-io/proton-rust-client/issues/6
20 client_without_compression: Client,
21 url: String,
22}
23
24impl ProtonClient {
25 /// Creates a new Proton client instance.
26 ///`
27 /// # Arguments
28 ///
29 /// * `url` - The base URL of the Proton API endpoint.
30 ///
31 /// # Returns
32 ///
33 /// Returns a new Proton client instance with the provided base URL.
34 ///
35 /// # Example
36 ///
37 /// ```no_run
38 /// use proton_client::ProtonClient;
39 ///
40 /// let client = ProtonClient::new("http://localhost:8123");
41 /// ```
42 pub fn new(url: &str) -> Self {
43 let client = Client::default().with_url(url.to_string());
44 let client_without_compression =
45 Client::with_compression(client.clone(), Compression::None);
46 let url = url.to_string();
47 Self {
48 client,
49 client_without_compression,
50 url,
51 }
52 }
53}