Documentation
¶
Index ¶
- Variables
- func ClickhouseValidateConfig(clickhouseConfig *ClickhouseConfig) error
- func Named(name string, value interface{}) driver.NamedValue
- type ClickhouseConfig
- type ClickhouseSession
- func (ch *ClickhouseSession) Close() error
- func (ch *ClickhouseSession) Conn() Conn
- func (chsession *ClickhouseSession) Connect(ch *ClickhouseConfig, ctx context.Context) error
- func (ch *ClickhouseSession) Exec(ctx context.Context, stmt string) error
- func (ch *ClickhouseSession) ExecWithArgs(ctx context.Context, stmt string, args ...interface{}) error
- func (ch *ClickhouseSession) Ping(ctx context.Context) error
- func (ch *ClickhouseSession) Query(ctx context.Context, query string) (Rows, error)
- func (ch *ClickhouseSession) QueryRow(ctx context.Context, query string, args ...interface{}) Row
- func (ch *ClickhouseSession) QueryWithArgs(ctx context.Context, query string, args ...interface{}) (Rows, error)
- type ClickhouseSessionInterface
- type ConfigLoaderInterface
- type ConfigValidatorInterface
- type Conn
- type DefaultConfigLoader
- type DefaultConfigValidator
- type DefaultSessionFactory
- type Options
- type Row
- type Rows
- type SessionFactoryInterface
Constants ¶
This section is empty.
Variables ¶
var DefaultRetryIntervals = []time.Duration{2 * time.Second, 3 * time.Second, 5 * time.Second}
DefaultRetryIntervals are the default retry intervals for production use. This can be overridden in tests for faster execution.
Functions ¶
func ClickhouseValidateConfig ¶
func ClickhouseValidateConfig(clickhouseConfig *ClickhouseConfig) error
validateConfig validates the loaded configuration.
func Named ¶ added in v1.3.41
func Named(name string, value interface{}) driver.NamedValue
Named creates a named parameter for use in queries. Re-exported from clickhouse-go for convenience.
Types ¶
type ClickhouseConfig ¶
type ClickhouseConfig struct {
ChHostname string `mapstructure:"chhostname"`
ChUsername string `mapstructure:"chusername"`
ChPassword string `mapstructure:"chpassword"`
ChDatabase string `mapstructure:"chdatabase"`
ChSkipVerify string `mapstructure:"chskipverify"`
ChPort string `mapstructure:"chport"`
}
func ClickhouseLoadConfig ¶
func ClickhouseLoadConfig() (*ClickhouseConfig, error)
LoadConfig loads the configuration from environment variables using Viper. Uses an isolated viper instance to avoid global state pollution that could affect other packages using viper with different env prefixes.
type ClickhouseSession ¶
type ClickhouseSession struct {
// contains filtered or unexported fields
}
ClickhouseSession implements ClickhouseSessionInterface
func NewClickhouseSession ¶
func NewClickhouseSession(ch *ClickhouseConfig, ctx context.Context) (*ClickhouseSession, error)
NewClickhouseSession creates a new Clickhouse session.
func (*ClickhouseSession) Close ¶
func (ch *ClickhouseSession) Close() error
Close ClickHouse connection
func (*ClickhouseSession) Conn ¶
func (ch *ClickhouseSession) Conn() Conn
return ClickHouse connection
func (*ClickhouseSession) Connect ¶
func (chsession *ClickhouseSession) Connect(ch *ClickhouseConfig, ctx context.Context) error
Connect to ClickHouse database
func (*ClickhouseSession) Exec ¶
func (ch *ClickhouseSession) Exec(ctx context.Context, stmt string) error
Exec ClickHouse query
func (*ClickhouseSession) ExecWithArgs ¶ added in v1.3.41
func (ch *ClickhouseSession) ExecWithArgs(ctx context.Context, stmt string, args ...interface{}) error
ExecWithArgs executes a statement with arguments
func (*ClickhouseSession) Ping ¶ added in v1.3.68
func (ch *ClickhouseSession) Ping(ctx context.Context) error
Ping verifies the connection to ClickHouse is alive.
func (*ClickhouseSession) QueryRow ¶ added in v1.3.41
func (ch *ClickhouseSession) QueryRow(ctx context.Context, query string, args ...interface{}) Row
QueryRow executes a query with arguments and returns a single row Note: QueryRow doesn't return an error directly; errors are deferred until Scan() is called. Therefore, retry logic is not applicable here.
func (*ClickhouseSession) QueryWithArgs ¶ added in v1.3.41
func (ch *ClickhouseSession) QueryWithArgs(ctx context.Context, query string, args ...interface{}) (Rows, error)
QueryWithArgs executes a query with arguments and returns rows
type ClickhouseSessionInterface ¶ added in v1.3.26
type ClickhouseSessionInterface interface {
Connect(ch *ClickhouseConfig, ctx context.Context) error
Ping(ctx context.Context) error
Query(ctx context.Context, query string) (Rows, error)
QueryWithArgs(ctx context.Context, query string, args ...interface{}) (Rows, error)
QueryRow(ctx context.Context, query string, args ...interface{}) Row
Exec(ctx context.Context, stmt string) error
ExecWithArgs(ctx context.Context, stmt string, args ...interface{}) error
Close() error
Conn() Conn
}
ClickhouseSessionInterface defines the interface for ClickHouse session operations
func NewSessionFromConn ¶ added in v1.3.41
func NewSessionFromConn(conn Conn) ClickhouseSessionInterface
NewSessionFromConn creates a ClickhouseSessionInterface from an existing connection. This is useful for backward compatibility or when you already have an established connection.
type ConfigLoaderInterface ¶ added in v1.3.26
type ConfigLoaderInterface interface {
LoadConfig() (*ClickhouseConfig, error)
}
ConfigLoaderInterface defines the interface for configuration loading
type ConfigValidatorInterface ¶ added in v1.3.26
type ConfigValidatorInterface interface {
ValidateConfig(config *ClickhouseConfig) error
}
ConfigValidatorInterface defines the interface for configuration validation
type DefaultConfigLoader ¶ added in v1.3.26
type DefaultConfigLoader struct{}
DefaultConfigLoader implements ConfigLoaderInterface
func (*DefaultConfigLoader) LoadConfig ¶ added in v1.3.26
func (c *DefaultConfigLoader) LoadConfig() (*ClickhouseConfig, error)
LoadConfig implements ConfigLoaderInterface
type DefaultConfigValidator ¶ added in v1.3.26
type DefaultConfigValidator struct{}
DefaultConfigValidator implements ConfigValidatorInterface
func (*DefaultConfigValidator) ValidateConfig ¶ added in v1.3.26
func (v *DefaultConfigValidator) ValidateConfig(config *ClickhouseConfig) error
ValidateConfig implements ConfigValidatorInterface
type DefaultSessionFactory ¶ added in v1.3.26
type DefaultSessionFactory struct{}
DefaultSessionFactory implements SessionFactoryInterface
func (*DefaultSessionFactory) NewSession ¶ added in v1.3.26
func (f *DefaultSessionFactory) NewSession( ch *ClickhouseConfig, ctx context.Context, ) (ClickhouseSessionInterface, error)
NewSession implements SessionFactoryInterface
type Options ¶ added in v1.3.41
type Options = clickhouse.Options
Options is the ClickHouse connection options type
type SessionFactoryInterface ¶ added in v1.3.26
type SessionFactoryInterface interface {
NewSession(ch *ClickhouseConfig, ctx context.Context) (ClickhouseSessionInterface, error)
}
SessionFactoryInterface defines the interface for creating ClickHouse sessions
Directories
¶
| Path | Synopsis |
|---|---|
|
Package clickhousetest provides test fixtures for the clickhouse package.
|
Package clickhousetest provides test fixtures for the clickhouse package. |