Skip to content

Release v1.3.0: ClickHouse Client

Choose a tag to compare

@sushant8421 sushant8421 released this 20 Jun 08:47

πŸš€ New Features

ClickHouse Client

  • High-Performance Database Client: Complete ClickHouse integration with schema-based operations
  • Zero-Reflection Operations: Optimized for performance with minimal overhead
  • Batch Processing: Configurable batch sizes for bulk operations
  • Async Inserts: Non-blocking inserts with connection-level async settings
  • Connection Pooling: Efficient connection management and prepared statement caching

Schema Management

  • Schema-Based Operations: Define table schemas and perform optimized inserts
  • Multiple Engine Support: ReplacingMergeTree and MergeTree engines
  • Table Creation: Automated table creation from schema definitions
  • IST Timezone Support: Full support for Asia/Kolkata timezone

Performance & Monitoring

  • Performance Monitoring: Connection statistics and performance metrics
  • Bulk Performance Testing: Comprehensive testing utilities included
  • Prepared Statement Caching: Automatic caching for repeated operations

πŸ› οΈ Technical Details

Clean API Design

  • Removed unnecessary type validation for cleaner, simpler API
  • Minimal dependencies and focused functionality
  • Trust-based approach - relies on ClickHouse driver for type handling

Configuration

  • Flexible connection configuration with ClickHouseConfig
  • Async insert settings with AsyncConfig
  • Engine configuration with EngineConfig

πŸ“¦ Dependencies Added

  • github.com/ClickHouse/clickhouse-go/v2 v2.37.1

πŸ”§ Usage

import "github.com/city-mall/go-utils/db/clickhouse"

// Create client
config := clickhouse.ClickHouseConfig{
    Host:     "localhost",
    Port:     9000,
    Database: "default",
    Username: "default",
    Password: "password",
}

client, err := clickhouse.NewClient(config)
if err != nil {
    log.Fatal(err)
}
defer client.Close()

// Define schema and create table
schema := &clickhouse.TableSchema{
    TableName: "events",
    Fields: []clickhouse.FieldSchema{
        {Name: "ID", ColumnName: "id", ClickHouseType: "UInt64"},
        {Name: "Name", ColumnName: "name", ClickHouseType: "String"},
    },
    Engine: clickhouse.DefaultEngineConfig(),
    PartitionBy: "toYYYYMMDD(timestamp)",
    PrimaryKey: []string{"id"},
}

err = client.CreateTableFromSchema(ctx, schema)

🎯 What's Next

This release establishes the foundation for high-performance ClickHouse operations in the go-utils library. Future releases will build upon this solid foundation.