mirror of
https://github.com/hanzo-ds/rs.git
synced 2026-10-30 20:49:56 +00:00
Cut from the upstream v0.13.3 release tag (not HEAD) so this is a pure
rename with no behaviour change. v0.13.3 is what our consumers already
resolve to: insights/rust's Cargo.lock pins clickhouse 0.13.3 and its
manifest already declares `datastore` at 0.13.x.
The load-bearing change is the HTTP auth header rename. The Datastore
server reads only X-Datastore-User / X-Datastore-Key; the upstream names
return `401 Code: 194 Authentication failed`. Every un-renamed HTTP
client is therefore unable to authenticate at all — this is a
correctness fix, not branding.
- crate `clickhouse` -> `datastore`, `clickhouse-derive` -> `datastore-derive`;
versions preserved exactly (0.13.3 / 0.2.0).
- derive macro emits `datastore::Row` in lockstep, so downstream
`#[derive(Row)]` keeps resolving.
- User-Agent reports `datastore-rs/{version}`.
- test-harness env vars CLICKHOUSE_* -> DATASTORE_*; compose uses
ghcr.io/hanzoai/datastore with /etc/datastore-server config paths.
- doc links point at docs.hanzo.ai/datastore.
- `publish = false`: the `datastore` name on crates.io belongs to an
unrelated crate, so consume this by git tag, never by version range.
CHANGELOG is truncated to a fork notice rather than find-replaced —
rewriting upstream release history would manufacture changes Datastore
never shipped. References to upstream issues keep their numbers.
31 lines
1.1 KiB
Rust
31 lines
1.1 KiB
Rust
use std::time::Duration;
|
|
|
|
use hyper_util::client::legacy::connect::HttpConnector;
|
|
use hyper_util::client::legacy::Client as HyperClient;
|
|
use hyper_util::rt::TokioExecutor;
|
|
|
|
use datastore::{error::Result, Client};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let connector = HttpConnector::new(); // or HttpsConnectorBuilder
|
|
let hyper_client = HyperClient::builder(TokioExecutor::new())
|
|
// For how long keep a particular idle socket alive on the client side (in milliseconds).
|
|
// It is supposed to be a fair bit less that the Datastore server KeepAlive timeout,
|
|
// which was by default 3 seconds for pre-23.11 versions, and 10 seconds after that.
|
|
.pool_idle_timeout(Duration::from_millis(2_500))
|
|
// Sets the maximum idle Keep-Alive connections allowed in the pool.
|
|
.pool_max_idle_per_host(4)
|
|
.build(connector);
|
|
|
|
let client = Client::with_http_client(hyper_client).with_url("http://localhost:8123");
|
|
|
|
let numbers = client
|
|
.query("SELECT number FROM system.numbers LIMIT 1")
|
|
.fetch_all::<u64>()
|
|
.await?;
|
|
println!("Numbers: {numbers:?}");
|
|
|
|
Ok(())
|
|
}
|