Documentation
¶
Overview ¶
Package clickhouse provides a ClickHouse client implementation
Index ¶
Constants ¶
const ( Scheme = "clickhouse" SchemeHTTPS = "https" SchemeHTTP = "http" PortNative = "9000" PortNativeTLS = "9440" )
Protocol constants for URL parsing.
Variables ¶
var ( ErrDestMustBePointerToSlice = errors.New("dest must be a pointer to a slice") ErrDestMustBePointer = errors.New("dest must be a pointer") ErrDataMustBeSlice = errors.New("data must be a slice") ErrResponse = errors.New("clickhouse error") ErrPoolStalled = errors.New("clickhouse connection pool stalled") )
Define static errors.
var ErrInvalidUint64 = errors.New("failed to unmarshal value as uint64")
ErrInvalidUint64 is returned when a value cannot be unmarshaled or scanned as uint64.
var (
ErrURLRequired = errors.New("URL is required")
)
Static errors for configuration validation
Functions ¶
func TableExists ¶
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
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 any) error
// QueryMany executes a query and returns multiple results
QueryMany(ctx context.Context, query string, dest any) error
// Execute runs a query without returning results (INSERT, ALTER, etc.)
Execute(ctx context.Context, query string) error
// BulkInsert performs a bulk insert operation
BulkInsert(ctx context.Context, table string, data any) error
// Start initializes the client
Start() error
// Stop closes the client
Stop() error
}
ClientInterface defines the methods for interacting with ClickHouse.
type Config ¶
type Config struct {
// URL supports multiple formats:
// - Native: clickhouse://user:pass@host:9000
// - HTTP: http://user:pass@host:8123
URL string `yaml:"url" validate:"required"`
Cluster string `yaml:"cluster"`
LocalSuffix string `yaml:"localSuffix"`
QueryTimeout time.Duration `yaml:"queryTimeout"`
InsertTimeout time.Duration `yaml:"insertTimeout"`
Debug bool `yaml:"debug"`
// Connection pool settings
MaxOpenConns int `yaml:"maxOpenConns"`
MaxIdleConns int `yaml:"maxIdleConns"`
ConnMaxLifetime time.Duration `yaml:"connMaxLifetime"`
// TLS settings
InsecureSkipVerify bool `yaml:"insecureSkipVerify"`
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
type FlexUint64 ¶ added in v0.1.7
type FlexUint64 uint64
FlexUint64 is a custom type that can unmarshal from both string and number JSON values and scan from string or numeric database columns.
func (*FlexUint64) Scan ¶ added in v0.1.7
func (f *FlexUint64) Scan(src any) error
Scan implements sql.Scanner for FlexUint64 to handle database values. Supports string columns (e.g., '123') and numeric columns.
func (*FlexUint64) UnmarshalJSON ¶ added in v0.1.7
func (f *FlexUint64) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for FlexUint64.
type HealthChecker ¶ added in v0.1.7
type HealthChecker interface {
Healthy() error
}
HealthChecker is implemented by clients that can report whether their connection pool is still able to hand out connections.