chkit

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBSQL

func NewDBSQL(addr string, opts ...Option) (*sql.DB, error)

NewDBSQL establishes connection with Clickhouse server. Returns a pointer to a new instance of sql.DB. Slower than New. Used mostly for backward compatibility with sql.DB compatible interfaces.

Types

type AsyncInsertConfig

type AsyncInsertConfig struct {
	// contains filtered or unexported fields
}

AsyncInsertConfig holds configuration for server-side asynchronous inserts.

type AsyncInsertOption

type AsyncInsertOption func(c *AsyncInsertConfig)

AsyncInsertOption configures the async insert behavior.

func BusyTimeout

func BusyTimeout(timeout int) AsyncInsertOption

BusyTimeout sets the max time in ms to wait before flush (e.g., 5000 = 5 seconds).

func MaxDataSize

func MaxDataSize(size int) AsyncInsertOption

MaxDataSize sets the buffer size in bytes before flush (e.g., 10485760 = 10MB).

func WaitForInsert

func WaitForInsert() AsyncInsertOption

WaitForInsert enables waiting for server-side flush, ensuring durability.

type Conn

type Conn struct {
	driver.Conn
	// contains filtered or unexported fields
}

Conn represents connection to ClickHouse database.

func New

func New(addr string, opts ...Option) (*Conn, error)

New establishes connection with Clickhouse server. Returns a pointer to a new instance of Conn struct.

func (*Conn) Health

func (c *Conn) Health(ctx context.Context) error

func (*Conn) MarkHealthy

func (c *Conn) MarkHealthy()

func (*Conn) MarkUnhealthy

func (c *Conn) MarkUnhealthy(err error)

type Option

type Option func(options *clickhouse.Options)

Option configures the ClickHouse client options.

func WithAsyncInsert

func WithAsyncInsert(opts ...AsyncInsertOption) Option

WithAsyncInsert enables asynchronous inserts on the server side. This reduces write IOPS by batching multiple insert operations on the ClickHouse server. Async inserts replace client-side batching — the server handles all buffering and flushing.

func WithAuth

func WithAuth(database, username, password string) Option

WithAuth configures the authentication credentials for the ClickHouse client.

func WithConnectionPool

func WithConnectionPool(maxOpenConns, maxIdleConns int) Option

WithConnectionPool configures the connection pool for high-concurrency scenarios. For high-throughput applications (1000+ concurrent requests), increase pool size accordingly. Recommended settings:

  • maxOpenConns: Maximum number of open connections (e.g., 100-200 for high load)
  • maxIdleConns: Maximum number of idle connections to keep (e.g., 50-100)

Jump to

Keyboard shortcuts

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