clickhouse

package
v0.0.1-0...-ce92ebd Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

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 {
	*ClusterEndpointCredentials
	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) SetEndpointCredentials

func (c *Cluster) SetEndpointCredentials(endpointCredentials *ClusterEndpointCredentials) *Cluster

SetEndpointCredentials sets endpoint credentials

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 ClusterEndpointCredentials

type ClusterEndpointCredentials struct {
	Scheme   string
	Username string
	Password string
	Port     int
}

ClusterEndpointCredentials specifies cluster endpoint credentials

type Connection

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

Connection specifies clickhouse database connection object

func GetPooledDBConnection

func GetPooledDBConnection(params *ConnectionParams) *Connection

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

func NewConnection

func NewConnection(params *ConnectionParams) *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() *ConnectionParams

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 ConnectionParams

type ConnectionParams struct {
	*EndpointCredentials
	*Timeouts
}

ConnectionParams represents connection parameters

func NewConnectionParams

func NewConnectionParams(scheme, hostname, username, password string, port int) *ConnectionParams

NewConnectionParams creates new ConnectionParams

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 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) UnzipColumnsAsStrings

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

UnzipColumnsAsStrings splits result table into string columns

type TimeLimitedConnector

type TimeLimitedConnector interface {
	GetConnectTimeout() time.Duration
	SetConnectTimeout(timeout time.Duration)
	GetQueryTimeout() time.Duration
	SetQueryTimeout(timeout time.Duration)
}

TimeLimitedConnector specifies interface to operate with timeouts on connection

type Timeouts

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

Timeouts specifies set of timeouts for a clickhouse connection

func NewTimeouts

func NewTimeouts() *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)

SetConnectTimeout sets connect timeout

func (*Timeouts) SetQueryTimeout

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

SetQueryTimeout sets query timeout

Jump to

Keyboard shortcuts

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