clickhouse

package module
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 9 Imported by: 0

README

helix.go - ClickHouse integration

Website Go API reference Go Report Card GitHub Release

The ClickHouse integration provides an opinionated way to interact with ClickHouse as OLAP database for helix services.

Documentation

Overview

Package clickhouse exposes an opinionated way to interact with ClickHouse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	Append(ctx context.Context, v any) error
	Abort(ctx context.Context) error
	Flush(ctx context.Context) error
	Send(ctx context.Context) error
	IsSent(ctx context.Context) bool
}

Batch exposes an opinionated way to interact with a ClickHouse batch capabilities. All functions are wrapped with a context because some of them automatically do distributed tracing (by using the said context) as well as error recording within traces.

type ClickHouse

type ClickHouse interface {
	Query(ctx context.Context, query string, args ...any) (driver.Rows, error)
	QueryRow(ctx context.Context, query string, args ...any) driver.Row
	PrepareBatch(ctx context.Context, query string) (Batch, error)
	Exec(ctx context.Context, query string, args ...any) error
	AsyncInsert(ctx context.Context, query string, wait bool) error
}

ClickHouse exposes an opinionated way to interact with ClickHouse, by bringing automatic distributed tracing as well as error recording within traces.

func Connect

func Connect(cfg Config) (ClickHouse, error)

Connect tries to connect to the ClickHouse server given the Config. Returns an error if Config is not valid or if the connection failed.

type Config

type Config struct {

	// Addresses are ClickHouse addresses to connect to.
	//
	// Default:
	//
	//   []string{"127.0.0.1:8123"}
	Addresses []string `json:"addresses"`

	// Database is the database to connect to.
	//
	// Default:
	//
	//   "default"
	Database string `json:"-"`

	// User is the user to use to connect to the database.
	User string `json:"-"`

	// Password is the user's password to connect to the database.
	Password string `json:"-"`

	// TLSConfig configures TLS to communicate with the ClickHouse server.
	TLS integration.ConfigTLS `json:"tls"`
}

Config is used to configure the ClickHouse integration.

Jump to

Keyboard shortcuts

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