Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
include:
- { rust: stable, os: ubuntu-22.04 }
- { rust: stable, os: ubuntu-24.04 }
services:
clickhouse:
image: clickhouse/clickhouse-server:25.8.4
Expand All @@ -28,7 +28,7 @@ jobs:
--ulimit nofile=262144:262144
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
Expand All @@ -49,7 +49,7 @@ jobs:
fail-fast: false
matrix:
include:
- { rust: 1.75.0, os: ubuntu-22.04 }
- { rust: 1.85.0, os: ubuntu-24.04 }
services:
clickhouse:
image: clickhouse/clickhouse-server:25.8.4
Expand All @@ -61,7 +61,7 @@ jobs:
--ulimit nofile=262144:262144
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -84,10 +84,10 @@ jobs:
fail-fast: false
matrix:
include:
- { rust: nightly-2024-03-31, os: ubuntu-22.04 }
- { rust: nightly-2026-03-10, os: ubuntu-24.04 }
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -108,10 +108,10 @@ jobs:
fail-fast: false
matrix:
include:
- { rust: stable, os: ubuntu-22.04 }
- { rust: stable, os: ubuntu-24.04 }
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -129,10 +129,10 @@ jobs:
# fail-fast: false
# matrix:
# include:
# - { rust: stable, os: ubuntu-22.04 }
# - { rust: stable, os: ubuntu-24.04 }
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# uses: actions/checkout@v6
# with:
# submodules: true
# - uses: dtolnay/rust-toolchain@stable
Expand Down
4 changes: 2 additions & 2 deletions klickhouse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
name = "klickhouse"
version = "0.14.0"
authors = ["Protryon <max.bruce12@gmail.com>"]
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
repository = "https://github.com/Protryon/klickhouse"
description = "Klickhouse is a pure Rust SDK for working with Clickhouse with the native protocol in async environments with minimal boilerplate and maximal performance."
keywords = ["clickhouse", "database", "tokio", "sql"]
readme = "../README.md"
autotests = false
rust-version = "1.75.0"
rust-version = "1.85.0"

[package.metadata.docs.rs]
all-features = true
Expand Down
44 changes: 29 additions & 15 deletions klickhouse/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use chrono::Utc;
use futures_util::StreamExt;
use klickhouse::*;
use tokio::sync::oneshot;

#[derive(Row, Debug, Default)]
pub struct MyUserData {
Expand All @@ -18,25 +19,38 @@ async fn main() {
.await
.unwrap();

let (tx, mut rx) = oneshot::channel::<()>();

// Retrieve and display query progress events
let mut progress = client.subscribe_progress();
let progress_task = tokio::task::spawn(async move {
let mut current_query = Uuid::nil();
let mut progress_total = Progress::default();
while let Ok((query, progress)) = progress.recv().await {
if query != current_query {
progress_total = Progress::default();
current_query = query;

loop {
tokio::select! {
// Stop task
_ = &mut rx => {
break
}

// Progress loop
Ok((query, progress)) = progress.recv() => {
if query != current_query {
progress_total = Progress::default();
current_query = query;
}
progress_total += progress;
println!(
"Progress on query {}: {}/{} {:.2}%",
query,
progress_total.read_rows,
progress_total.new_total_rows_to_read,
100.0 * progress_total.read_rows as f64
/ progress_total.new_total_rows_to_read as f64
);
}
}
progress_total += progress;
println!(
"Progress on query {}: {}/{} {:.2}%",
query,
progress_total.read_rows,
progress_total.new_total_rows_to_read,
100.0 * progress_total.read_rows as f64
/ progress_total.new_total_rows_to_read as f64
);
}
});

Expand Down Expand Up @@ -81,7 +95,7 @@ async fn main() {
println!("row received '{}': {:?}", row.id, row);
}

// Drop the client so that the progress task finishes.
drop(client);
// Send signal so that the progress task finishes.
tx.send(()).unwrap();
progress_task.await.unwrap();
}
44 changes: 29 additions & 15 deletions klickhouse/examples/pool.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use chrono::Utc;
use futures_util::StreamExt;
use klickhouse::*;
use tokio::sync::oneshot;

#[derive(Row, Debug, Default)]
pub struct MyUserData {
Expand All @@ -26,25 +27,38 @@ async fn main() {

let client = pool.get().await.unwrap();

let (tx, mut rx) = oneshot::channel::<()>();

// Retrieve and display query progress events
let mut progress = client.subscribe_progress();
let progress_task = tokio::task::spawn(async move {
let mut current_query = Uuid::nil();
let mut progress_total = Progress::default();
while let Ok((query, progress)) = progress.recv().await {
if query != current_query {
progress_total = Progress::default();
current_query = query;

loop {
tokio::select! {
// Stop task
_ = &mut rx => {
break
}

// Progress loop
Ok((query, progress)) = progress.recv() => {
if query != current_query {
progress_total = Progress::default();
current_query = query;
}
progress_total += progress;
println!(
"Progress on query {}: {}/{} {:.2}%",
query,
progress_total.read_rows,
progress_total.new_total_rows_to_read,
100.0 * progress_total.read_rows as f64
/ progress_total.new_total_rows_to_read as f64
);
}
}
progress_total += progress;
println!(
"Progress on query {}: {}/{} {:.2}%",
query,
progress_total.read_rows,
progress_total.new_total_rows_to_read,
100.0 * progress_total.read_rows as f64
/ progress_total.new_total_rows_to_read as f64
);
}
});

Expand Down Expand Up @@ -89,7 +103,7 @@ async fn main() {
println!("row received '{}': {:?}", row.id, row);
}

// Drop the client so that the progress task finishes.
drop(client);
// Send signal so that the progress task finishes.
tx.send(()).unwrap();
progress_task.await.unwrap();
}
2 changes: 1 addition & 1 deletion klickhouse/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
edition = "2021"
edition = "2024"
2 changes: 1 addition & 1 deletion klickhouse/src/convert/std_deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl<T: FromSql> FromSql for Box<T> {
}

macro_rules! tuple_impls {
($($len:expr => ($($n:tt $name:ident)+))+) => {
($($len:literal => ($($n:tt $name:ident)+))+) => {
$(
impl<$($name: FromSql),+> FromSql for ($($name,)+) {
fn from_sql(type_: &Type, value: Value) -> Result<Self> {
Expand Down
2 changes: 1 addition & 1 deletion klickhouse/src/convert/std_serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<T: ToSql> ToSql for Box<T> {
}

macro_rules! tuple_impls {
($($len:expr => ($($n:tt $name:ident)+))+) => {
($($len:literal => ($($n:tt $name:ident)+))+) => {
$(
impl<$($name: ToSql),+> ToSql for ($($name,)+) {
fn to_sql(self, type_hint: Option<&Type>) -> Result<Value> {
Expand Down
4 changes: 2 additions & 2 deletions klickhouse_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
name = "klickhouse_derive"
version = "0.13.0"
authors = ["Protryon <max.bruce12@gmail.com>"]
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
repository = "https://github.com/Protryon/klickhouse"
description = "proc-macro crate for klickhouse"
keywords = [ "clickhouse", "database", "tokio", "sql" ]
rust-version = "1.75.0"
rust-version = "1.85.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
Loading