Skip to content

Conversation

@koxudaxi
Copy link
Collaborator

@koxudaxi koxudaxi commented Jan 6, 2026

TL;DR

Added ClickHouse client implementation for analytics data access with support for both Node.js and Cloudflare Workers environments.

What changed?

  • Added @clickhouse/client dependency to the project
  • Created a new ClickHouseClient service with two implementations:
    • ClickHouseClientNodeLive: Uses the native Node.js client for local development and API handlers
    • ClickHouseClientWorkersLive: Uses fetch API with HTTP interface for Cloudflare Workers
  • Added comprehensive test coverage for both implementations
  • Extended the Settings interface with ClickHouse configuration options
  • Added ClickHouseError class for error handling
  • Implemented environment-specific TLS validation for secure connections

How to test?

  1. Run the test suite to verify both implementations:

    cd cloud
    bun test clickhouse/client.test.ts
  2. For local development with ClickHouse:

    import { ClickHouseClient, ClickHouseClientNodeLive } from "@/clickhouse/client";
    
    const program = Effect.gen(function* () {
      const client = yield* ClickHouseClient;
      const results = yield* client.query("SELECT * FROM test_table LIMIT 10");
      return results;
    });
    
    await Effect.runPromise(program.pipe(Effect.provide(ClickHouseClientNodeLive)));

Why make this change?

This implementation provides a unified interface for analytics data access across different environments. The dual implementation approach solves the platform-specific constraints:

  1. Node.js environment (local dev, API handlers) gets full TLS configuration support with the native client
  2. Cloudflare Workers environment (Queue Consumer, Cron) gets a compatible implementation using the HTTP API

This enables consistent analytics data access while respecting the runtime constraints of each platform.

Copy link
Collaborator Author

koxudaxi commented Jan 6, 2026

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 6, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
v2-docs 54d36f0 Jan 09 2026, 03:37 AM

@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from 812fcfb to 51f6895 Compare January 6, 2026 08:14
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from d98ff1a to 379c7c3 Compare January 6, 2026 08:14
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from 379c7c3 to 94cc04c Compare January 6, 2026 08:22
@koxudaxi koxudaxi changed the base branch from 01-06-feat_docker_add_clickhouse_service_for_local_development to graphite-base/1808 January 6, 2026 08:22
@koxudaxi koxudaxi force-pushed the graphite-base/1808 branch from 51f6895 to 0a6f3f4 Compare January 6, 2026 08:32
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from 94cc04c to 72230a9 Compare January 6, 2026 08:32
@koxudaxi koxudaxi changed the base branch from graphite-base/1808 to 01-06-feat_docker_add_clickhouse_service_for_local_development January 6, 2026 08:33
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from 72230a9 to db31c84 Compare January 6, 2026 08:36
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from 0a6f3f4 to 311c705 Compare January 6, 2026 08:36
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from db31c84 to f02b009 Compare January 6, 2026 08:41
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from 311c705 to 2ed27e7 Compare January 6, 2026 08:41
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from f02b009 to f3a92e1 Compare January 6, 2026 08:44
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch 2 times, most recently from 2b38b01 to a773199 Compare January 6, 2026 08:45
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch 2 times, most recently from 7a8dde2 to 6c944df Compare January 6, 2026 08:49
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from a773199 to b375648 Compare January 6, 2026 08:49
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from d35b09f to e717c79 Compare January 8, 2026 12:10
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from f304bba to b48b0e8 Compare January 8, 2026 12:21
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from e717c79 to 795a24b Compare January 8, 2026 12:21
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from b48b0e8 to f7e727e Compare January 8, 2026 13:25
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from 795a24b to 0a64910 Compare January 8, 2026 13:25
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from 0a64910 to dca4196 Compare January 8, 2026 14:20
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from f7e727e to ff98703 Compare January 8, 2026 14:36
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from dca4196 to ab1f5cd Compare January 8, 2026 14:36
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from ff98703 to b99dbd3 Compare January 8, 2026 18:03
@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch 2 times, most recently from 1bfbeaa to a4f0b7e Compare January 8, 2026 18:09
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from b99dbd3 to 3bd2c0e Compare January 8, 2026 18:09
Copy link
Collaborator

willbakst commented Jan 9, 2026

Merge activity

@koxudaxi koxudaxi force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from a4f0b7e to 2010b84 Compare January 9, 2026 03:11
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from 3bd2c0e to 03c0acf Compare January 9, 2026 03:11
@willbakst willbakst force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch 2 times, most recently from c95780a to 145ccd6 Compare January 9, 2026 03:16
@willbakst willbakst force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from 2010b84 to a760968 Compare January 9, 2026 03:16
@willbakst willbakst changed the base branch from 01-06-feat_docker_add_clickhouse_service_for_local_development to graphite-base/1808 January 9, 2026 03:23
koxudaxi and others added 2 commits January 9, 2026 03:24
Add Effect-native ClickHouse client with:
- ClickHouseClient class with static Default and layer methods
- Node.js implementation using @clickhouse/client
- Cloudflare Workers implementation using fetch + HTTP API
- TLS configuration support for Node.js
- ClickHouseConfig type for direct configuration

Architecture follows DrizzleORM pattern:
- ClickHouseClient.Default - requires SettingsService
- ClickHouseClient.layer(config) - direct config, no dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@willbakst willbakst force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from a760968 to b005731 Compare January 9, 2026 03:24
@willbakst willbakst changed the base branch from graphite-base/1808 to v2 January 9, 2026 03:24
@willbakst willbakst force-pushed the 01-06-feat_clickhouse_implement_clickhouse_client_service branch from b005731 to 54d36f0 Compare January 9, 2026 03:24
@willbakst willbakst merged commit 3488bbf into v2 Jan 9, 2026
10 of 11 checks passed
@willbakst willbakst deleted the 01-06-feat_clickhouse_implement_clickhouse_client_service branch January 9, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants