clickhouse

package
v0.0.0-...-d7ecc2e Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropHost

func DropHost(host string)

DropHost deletes host from the pool TODO we need to be able to remove entries from the pool

Types

type Cluster

type Cluster struct {
	*ClusterConnectionParams
	Hosts []string
	// contains filtered or unexported fields
}

Cluster specifies clickhouse cluster object

func NewCluster

func NewCluster() *Cluster

NewCluster creates new clickhouse cluster object

func (*Cluster) ExecAll

func (c *Cluster) ExecAll(ctx context.Context, queries []string, _opts ...*QueryOptions) error

ExecAll runs set of SQL queries on all endpoints of the cluster. No data is expected to be returned back. Retry logic traverses the list of SQLs multiple times until all SQLs succeed.

func (*Cluster) QueryAny

func (c *Cluster) QueryAny(ctx context.Context, sql string) (*QueryResult, error)

QueryAny walks over all endpoints and runs query sequentially on each of them. In case endpoint returned result, walk is completed and result is returned. In case endpoint failed, continue with the next endpoint.

func (*Cluster) SetHosts

func (c *Cluster) SetHosts(hosts []string) *Cluster

SetHosts sets hosts

func (*Cluster) SetLog

func (c *Cluster) SetLog(a log.Announcer) *Cluster

SetLog sets new logger/announcer

type ClusterConnectionParams

type ClusterConnectionParams struct {
	*ClusterCredentials
	*Timeouts
}

ClusterConnectionParams represents connection parameters to the whole cluster

func NewClusterConnectionParams

func NewClusterConnectionParams(scheme, username, password, rootCA string, port int) *ClusterConnectionParams

NewClusterConnectionParams creates new ClusterConnectionParams

func NewClusterConnectionParamsFromCHOpConfig

func NewClusterConnectionParamsFromCHOpConfig(config *api.OperatorConfig) *ClusterConnectionParams

NewClusterConnectionParamsFromCHOpConfig is the same as NewClusterConnectionParams, but works with CHOp config to get parameters from

func (*ClusterConnectionParams) NewEndpointConnectionParams

func (p *ClusterConnectionParams) NewEndpointConnectionParams(host string) *EndpointConnectionParams

NewEndpointConnectionParams creates endpoint connection params for a specified host in the cluster

func (*ClusterConnectionParams) SetTimeouts

func (p *ClusterConnectionParams) SetTimeouts(timeouts *Timeouts) *ClusterConnectionParams

SetTimeouts sets timeout

type ClusterCredentials

type ClusterCredentials struct {
	Scheme   string
	Username string
	Password string
	RootCA   string
	Port     int
}

ClusterCredentials specifies cluster endpoint credentials

func NewClusterCredentials

func NewClusterCredentials(scheme, username, password, rootCA string, port int) *ClusterCredentials

NewClusterCredentials creates new ClusterCredentials

type Connection

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

Connection specifies clickhouse database connection object

func GetPooledDBConnection

func GetPooledDBConnection(params *EndpointConnectionParams) *Connection

GetPooledDBConnection gets connection out of the pool. In case no connection available new connection is created and returned.

func NewConnection

func NewConnection(params *EndpointConnectionParams) *Connection

NewConnection creates new clickhouse connection

func (*Connection) Exec

func (c *Connection) Exec(_ctx context.Context, sql string, opts *QueryOptions) error

Exec runs given sql query

func (*Connection) Params

func (c *Connection) Params() *EndpointConnectionParams

Params gets connection params

func (*Connection) Query

func (c *Connection) Query(sql string) (*QueryResult, error)

Query runs given sql query

func (*Connection) QueryContext

func (c *Connection) QueryContext(ctx context.Context, sql string) (*QueryResult, error)

QueryContext runs given sql query on behalf of specified context

func (*Connection) SetLog

func (c *Connection) SetLog(l log.Announcer) *Connection

SetLog sets log announcer

type EndpointConnectionParams

type EndpointConnectionParams struct {
	*EndpointCredentials
	*Timeouts
}

EndpointConnectionParams represents connection parameters

func NewEndpointConnectionParams

func NewEndpointConnectionParams(scheme, hostname, username, password, rootCA string, port int) *EndpointConnectionParams

NewEndpointConnectionParams creates new EndpointConnectionParams

func (*EndpointConnectionParams) SetTimeouts

func (p *EndpointConnectionParams) SetTimeouts(timeouts *Timeouts) *EndpointConnectionParams

SetTimeouts sets timeout

type EndpointCredentials

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

EndpointCredentials specifies credentials to access specified endpoint

func NewEndpointCredentials

func NewEndpointCredentials(scheme, hostname, username, password, rootCA string, port int) *EndpointCredentials

NewEndpointCredentials creates new EndpointCredentials object

func (*EndpointCredentials) GetDSN

func (c *EndpointCredentials) GetDSN() string

GetDSN gets DSN

func (*EndpointCredentials) GetDSNWithHiddenCredentials

func (c *EndpointCredentials) GetDSNWithHiddenCredentials() string

GetDSNWithHiddenCredentials gets DSN with hidden sensitive info

type QueryOptions

type QueryOptions struct {
	Retry    bool
	Tries    int
	Parallel bool
	Silent   bool
	*Timeouts
}

QueryOptions specifies options of a query

func NewQueryOptions

func NewQueryOptions() *QueryOptions

NewQueryOptions creates new query options

func QueryOptionsNormalize

func QueryOptionsNormalize(opts ...*QueryOptions) *QueryOptions

QueryOptionsNormalize normalizes options

func (*QueryOptions) GetRetry

func (o *QueryOptions) GetRetry() bool

GetRetry gets retry option

func (*QueryOptions) GetSilent

func (o *QueryOptions) GetSilent() bool

GetSilent gets silent option

func (*QueryOptions) Normalize

func (o *QueryOptions) Normalize() *QueryOptions

Normalize normalizes options

func (*QueryOptions) SetRetry

func (o *QueryOptions) SetRetry(retry bool) *QueryOptions

SetRetry sets retry option

func (*QueryOptions) SetSilent

func (o *QueryOptions) SetSilent(silent bool) *QueryOptions

SetSilent sets silent option

type QueryResult

type QueryResult struct {

	// Query result rows
	Rows *databasesql.Rows
	// contains filtered or unexported fields
}

QueryResult specifies result of a query

func NewQueryResult

func NewQueryResult(ctx context.Context, cancelFunc context.CancelFunc, rows *databasesql.Rows) *QueryResult

NewQueryResult creates new query result

func (*QueryResult) Close

func (q *QueryResult) Close()

Close closes query result and releases all allocated resources. Should be called on each query result

func (*QueryResult) Int

func (q *QueryResult) Int() (int, error)

Int fetches one int from the query result

func (*QueryResult) String

func (q *QueryResult) String() (string, error)

String fetches one string from the query result

func (*QueryResult) UnzipColumnsAsStrings

func (q *QueryResult) UnzipColumnsAsStrings(columns ...*[]string) error

UnzipColumnsAsStrings splits result table into string columns

type Timeouts

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

Timeouts specifies set of timeouts for a clickhouse connection

func NewTimeouts

func NewTimeouts(timeouts ...time.Duration) *Timeouts

NewTimeouts creates new set of timeouts

func (*Timeouts) GetConnectTimeout

func (t *Timeouts) GetConnectTimeout() time.Duration

GetConnectTimeout gets connect timeout

func (*Timeouts) GetQueryTimeout

func (t *Timeouts) GetQueryTimeout() time.Duration

GetQueryTimeout gets query timeout

func (*Timeouts) SetConnectTimeout

func (t *Timeouts) SetConnectTimeout(timeout time.Duration) *Timeouts

SetConnectTimeout sets connect timeout

func (*Timeouts) SetQueryTimeout

func (t *Timeouts) SetQueryTimeout(timeout time.Duration) *Timeouts

SetQueryTimeout sets query timeout

Jump to

Keyboard shortcuts

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