clickhouse

package
v0.0.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2025 License: GPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clickhouse provides a ClickHouse client implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDestMustBePointerToSlice = errors.New("dest must be a pointer to a slice")
	ErrDataMustBeSlice          = errors.New("data must be a slice")
	ErrClickHouseResponse       = errors.New("clickhouse error")
)

Define static errors

View Source
var (
	ErrURLRequired = errors.New("URL is required")
)

Static errors for configuration validation

Functions

func TableExists

func TableExists(ctx context.Context, client ClientInterface, database, table string) (bool, error)

TableExists checks if a table exists in the given database

Types

type AdminConfig added in v0.0.25

type AdminConfig struct {
	Incremental AdminTableConfig `yaml:"incremental"`
	Scheduled   AdminTableConfig `yaml:"scheduled"`
}

AdminConfig contains configurations for different transformation type admin tables

type AdminTableConfig added in v0.0.25

type AdminTableConfig struct {
	Database string `yaml:"database"`
	Table    string `yaml:"table"`
}

AdminTableConfig represents the configuration for a type-specific admin table

type ClientInterface

type ClientInterface interface {
	// QueryOne executes a query and returns a single result
	QueryOne(ctx context.Context, query string, dest interface{}) error
	// QueryMany executes a query and returns multiple results
	QueryMany(ctx context.Context, query string, dest interface{}) error
	// Execute runs a query and returns the raw response body
	Execute(ctx context.Context, query string) ([]byte, error)
	// BulkInsert performs a bulk insert operation
	BulkInsert(ctx context.Context, table string, data interface{}) error
	// Start initializes the client
	Start() error
	// Stop closes the client
	Stop() error
}

ClientInterface defines the methods for interacting with ClickHouse

func NewClient

func NewClient(logger *logrus.Logger, cfg *Config) (ClientInterface, error)

NewClient creates a new HTTP-based ClickHouse client

type Config

type Config struct {
	URL           string        `yaml:"url" validate:"required,url"`
	Cluster       string        `yaml:"cluster"`
	LocalSuffix   string        `yaml:"localSuffix"`
	QueryTimeout  time.Duration `yaml:"queryTimeout"`
	InsertTimeout time.Duration `yaml:"insertTimeout"`
	Debug         bool          `yaml:"debug"`
	KeepAlive     time.Duration `yaml:"keepAlive"`
	Admin         AdminConfig   `yaml:"admin"`
}

Config contains ClickHouse connection and cluster settings

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults sets default values for the configuration

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL