clickhouse

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package clickhouse is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.3.0

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

func New

func New(config Config) *Client

New initializes Clickhouse client with the provided configuration. Metrics, Logger has to be initialized before calling the Connect method. Usage:

client.UseLogger(Logger())
client.UseMetrics(Metrics())

client.Connect()

func (*Client) AsyncInsert added in v0.3.0

func (c *Client) AsyncInsert(ctx context.Context, query string, wait bool, args ...any) error

AsyncInsert allows the user to specify whether the client should wait for the server to complete the insert or respond once the data has been received.

func (*Client) Connect added in v0.3.0

func (c *Client) Connect()

Connect establishes a connection to Clickhouse and registers metrics using the provided configuration when the client was Created.

func (*Client) Exec added in v0.3.0

func (c *Client) Exec(ctx context.Context, query string, args ...any) error

Exec should be used for DDL and simple statements. It should not be used for larger inserts or query iterations.

func (*Client) HealthCheck added in v0.3.0

func (c *Client) HealthCheck(ctx context.Context) (any, error)

HealthCheck checks the health of the MongoDB client by pinging the database.

func (*Client) Select added in v0.3.0

func (c *Client) Select(ctx context.Context, dest any, query string, args ...any) error

Select method allows a set of response rows to be marshaled into a slice of structs with a single invocation.. DB column names should be defined in the struct in `ch` tag. Example Usages:

type User struct {
	Id   string `ch:"id"`
	Name string `ch:"name"`
	Age  string `ch:"age"`
}

var user []User

err = ctx.Clickhouse.Select(ctx, &user, "SELECT * FROM users") .

func (*Client) UseLogger added in v0.3.0

func (c *Client) UseLogger(logger interface{})

UseLogger sets the logger for the Clickhouse client.

func (*Client) UseMetrics added in v0.3.0

func (c *Client) UseMetrics(metrics interface{})

UseMetrics sets the metrics for the Clickhouse client.

func (*Client) UseTracer added in v0.3.0

func (c *Client) UseTracer(tracer any)

UseTracer sets the tracer for Clickhouse client.

type Config

type Config struct {
	Hosts    string
	Username string
	Password string
	Database string
}

type Conn

type Conn interface {
	Select(ctx context.Context, dest any, query string, args ...any) error
	Exec(ctx context.Context, query string, args ...any) error
	AsyncInsert(ctx context.Context, query string, wait bool, args ...any) error
	Ping(context.Context) error
	Stats() driver.Stats
}

type Health

type Health struct {
	Status  string                 `json:"status,omitempty"`
	Details map[string]interface{} `json:"details,omitempty"`
}

type Log

type Log struct {
	Type     string        `json:"type"`
	Query    string        `json:"query"`
	Duration int64         `json:"duration"`
	Args     []interface{} `json:"args,omitempty"`
}

func (*Log) PrettyPrint

func (l *Log) PrettyPrint(writer io.Writer)

type Logger

type Logger interface {
	Debugf(pattern string, args ...interface{})
	Debug(args ...interface{})
	Logf(pattern string, args ...interface{})
	Errorf(patter string, args ...interface{})
}

type Metrics

type Metrics interface {
	NewHistogram(name, desc string, buckets ...float64)
	NewGauge(name, desc string)

	RecordHistogram(ctx context.Context, name string, value float64, labels ...string)
	SetGauge(name string, value float64, labels ...string)
}

type MockConn

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

MockConn is a mock of Conn interface.

func NewMockConn

func NewMockConn(ctrl *gomock.Controller) *MockConn

NewMockConn creates a new mock instance.

func (*MockConn) AsyncInsert

func (m *MockConn) AsyncInsert(ctx context.Context, query string, wait bool, args ...any) error

AsyncInsert mocks base method.

func (*MockConn) EXPECT

func (m *MockConn) EXPECT() *MockConnMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConn) Exec

func (m *MockConn) Exec(ctx context.Context, query string, args ...any) error

Exec mocks base method.

func (*MockConn) Ping

func (m *MockConn) Ping(arg0 context.Context) error

Ping mocks base method.

func (*MockConn) Select

func (m *MockConn) Select(ctx context.Context, dest any, query string, args ...any) error

Select mocks base method.

func (*MockConn) Stats

func (m *MockConn) Stats() driver.Stats

Stats mocks base method.

type MockConnMockRecorder

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

MockConnMockRecorder is the mock recorder for MockConn.

func (*MockConnMockRecorder) AsyncInsert

func (mr *MockConnMockRecorder) AsyncInsert(ctx, query, wait any, args ...any) *gomock.Call

AsyncInsert indicates an expected call of AsyncInsert.

func (*MockConnMockRecorder) Exec

func (mr *MockConnMockRecorder) Exec(ctx, query any, args ...any) *gomock.Call

Exec indicates an expected call of Exec.

func (*MockConnMockRecorder) Ping

func (mr *MockConnMockRecorder) Ping(arg0 any) *gomock.Call

Ping indicates an expected call of Ping.

func (*MockConnMockRecorder) Select

func (mr *MockConnMockRecorder) Select(ctx, dest, query any, args ...any) *gomock.Call

Select indicates an expected call of Select.

func (*MockConnMockRecorder) Stats

func (mr *MockConnMockRecorder) Stats() *gomock.Call

Stats indicates an expected call of Stats.

type MockLogger

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

MockLogger is a mock of Logger interface.

func NewMockLogger

func NewMockLogger(ctrl *gomock.Controller) *MockLogger

NewMockLogger creates a new mock instance.

func (*MockLogger) Debug

func (m *MockLogger) Debug(args ...any)

Debug mocks base method.

func (*MockLogger) Debugf

func (m *MockLogger) Debugf(pattern string, args ...any)

Debugf mocks base method.

func (*MockLogger) EXPECT

func (m *MockLogger) EXPECT() *MockLoggerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLogger) Errorf

func (m *MockLogger) Errorf(patter string, args ...any)

Errorf mocks base method.

func (*MockLogger) Logf

func (m *MockLogger) Logf(pattern string, args ...any)

Logf mocks base method.

type MockLoggerMockRecorder

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

MockLoggerMockRecorder is the mock recorder for MockLogger.

func (*MockLoggerMockRecorder) Debug

func (mr *MockLoggerMockRecorder) Debug(args ...any) *gomock.Call

Debug indicates an expected call of Debug.

func (*MockLoggerMockRecorder) Debugf

func (mr *MockLoggerMockRecorder) Debugf(pattern any, args ...any) *gomock.Call

Debugf indicates an expected call of Debugf.

func (*MockLoggerMockRecorder) Errorf

func (mr *MockLoggerMockRecorder) Errorf(patter any, args ...any) *gomock.Call

Errorf indicates an expected call of Errorf.

func (*MockLoggerMockRecorder) Logf

func (mr *MockLoggerMockRecorder) Logf(pattern any, args ...any) *gomock.Call

Logf indicates an expected call of Logf.

type MockMetrics

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

MockMetrics is a mock of Metrics interface.

func NewMockMetrics

func NewMockMetrics(ctrl *gomock.Controller) *MockMetrics

NewMockMetrics creates a new mock instance.

func (*MockMetrics) EXPECT

func (m *MockMetrics) EXPECT() *MockMetricsMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetrics) NewGauge

func (m *MockMetrics) NewGauge(name, desc string)

NewGauge mocks base method.

func (*MockMetrics) NewHistogram

func (m *MockMetrics) NewHistogram(name, desc string, buckets ...float64)

NewHistogram mocks base method.

func (*MockMetrics) RecordHistogram

func (m *MockMetrics) RecordHistogram(ctx context.Context, name string, value float64, labels ...string)

RecordHistogram mocks base method.

func (*MockMetrics) SetGauge

func (m *MockMetrics) SetGauge(name string, value float64, labels ...string)

SetGauge mocks base method.

type MockMetricsMockRecorder

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

MockMetricsMockRecorder is the mock recorder for MockMetrics.

func (*MockMetricsMockRecorder) NewGauge

func (mr *MockMetricsMockRecorder) NewGauge(name, desc any) *gomock.Call

NewGauge indicates an expected call of NewGauge.

func (*MockMetricsMockRecorder) NewHistogram

func (mr *MockMetricsMockRecorder) NewHistogram(name, desc any, buckets ...any) *gomock.Call

NewHistogram indicates an expected call of NewHistogram.

func (*MockMetricsMockRecorder) RecordHistogram

func (mr *MockMetricsMockRecorder) RecordHistogram(ctx, name, value any, labels ...any) *gomock.Call

RecordHistogram indicates an expected call of RecordHistogram.

func (*MockMetricsMockRecorder) SetGauge

func (mr *MockMetricsMockRecorder) SetGauge(name, value any, labels ...any) *gomock.Call

SetGauge indicates an expected call of SetGauge.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳