cheburcheck/website
LowderPlay 3a45460ff0
Some checks failed
Build Reporter / validate (push) Has been cancelled
Build and Publish Docker Images / validate (push) Has been cancelled
CodeQL Advanced / Analyze (rust) (push) Has been cancelled
Build Probe / validate (push) Has been cancelled
Build Reporter / Linux amd64 (.deb) (push) Has been cancelled
Build Reporter / Linux arm64 (.deb via cross) (push) Has been cancelled
Build Reporter / Windows amd64 (push) Has been cancelled
Build Reporter / release (push) Has been cancelled
Build and Publish Docker Images / Build website image (push) Has been cancelled
Build and Publish Docker Images / Build frontend image (push) Has been cancelled
Build and Publish Docker Images / Deploy (push) Has been cancelled
Build and Publish Docker Images / release (push) Has been cancelled
Build Probe / Linux amd64 binary and .deb (push) Has been cancelled
Build Probe / Linux arm64 binary, .deb, and OpenWrt packages (push) Has been cancelled
Build Probe / Windows amd64 binary (push) Has been cancelled
Build Probe / Docker image amd64/arm64/armv7 (push) Has been cancelled
Build Probe / release (push) Has been cancelled
feat: clickhouse storage (#106)
* feat: clickhouse storage

* feat: use deadpool for clickhouse

* chore: bump version
2026-10-13 03:48:33 +05:00
..
.sqlx feat: better layout (#94) 2026-09-24 19:16:55 +05:00
clickhouse feat: clickhouse storage (#106) 2026-10-13 03:48:33 +05:00
migrations feat: admin interface 2026-09-30 12:56:26 +05:00
src feat: clickhouse storage (#106) 2026-10-13 03:48:33 +05:00
static feat: add note about mobile whitelists 2026-03-11 23:02:58 +05:00
build.rs feat: clickhouse storage (#106) 2026-10-13 03:48:33 +05:00
Cargo.lock refactor: move to cargo workplace 2025-11-27 00:39:54 +05:00
Cargo.toml feat: clickhouse storage (#106) 2026-10-13 03:48:33 +05:00
Dockerfile fix: permissions 2026-06-18 04:03:59 +05:00
probe-hosts.toml feat: dpi traceroute commands and debug (#102) 2026-10-02 20:45:31 +05:00
README.md feat: clickhouse storage (#106) 2026-10-13 03:48:33 +05:00
Rocket.toml fix: configure upload limits 2025-12-12 06:41:51 +05:00

Website API

The API uses PostgreSQL for operational data and ClickHouse for query, probe, and feedback records. CLICKHOUSE_URL must identify an existing database over native TCP, for example clickhouse://user:password@host:9000/analytics. Percent-encode special characters in credentials. Add ?stats_timezone=Asia%2FYekaterinburg to change the complaint statistics timezone from UTC.

ClickHouse connection pool

All API requests share a Deadpool managed pool of independent native connections. A small adapter creates and checks klickhouse connections; Deadpool handles pool capacity, waiters, and connection reuse. Connections are opened on demand and checked out exclusively for each operation.

Environment variable Default Purpose
CLICKHOUSE_POOL_SIZE 4 Maximum simultaneous connections per API process.
CLICKHOUSE_ACQUIRE_TIMEOUT_SECONDS 5 Deadline for waiting for a slot and establishing its connection.
CLICKHOUSE_QUERY_TIMEOUT_SECONDS 10 Deadline for each API read or write.

Values must be positive integers. Docker Compose forwards these settings to the website service. Connection setup also has a ten-second upper limit, bounded by the acquisition deadline. Startup migrations have a separate 120-second deadline.

Cancelled, timed-out, and broken connections are closed and replaced on demand. Reads retry once after a connection failure, releasing the failed connection before acquiring another slot. Query timeouts are returned immediately. Writes are never automatically retried because a failed response may follow a committed insert.

Tests

Run the regular website tests with the checked-in SQLx metadata:

SQLX_OFFLINE=true cargo test --locked -p website

The ClickHouse integration tests require a disposable native server. They create and delete a temporary database, and the migration test needs database creation permissions:

SQLX_OFFLINE=true CLICKHOUSE_TEST_URL=clickhouse://localhost:9000/default \
  cargo test --locked -p website analytics::tests -- --include-ignored