Documentation
¶
Overview ¶
The code on this file is mostly imported from the clickhouse-go project in https://github.com/ClickHouse/clickhouse-go/blob/main/struct_map.go; The original license is maintained
Licensed to ClickHouse, Inc. under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. ClickHouse, Inc. licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func ColumnExists(ctx context.Context, client *Client, database string, table string, ...) (bool, error)
- func CurrentDatabase(ctx context.Context, client *Client) (string, error)
- func DialectOptions() *goqu.SQLDialectOptions
- func NewMigrationManager(ctx context.Context, client *Client, opts ...ChMigrationOption) (migrations.Manager, error)
- func TableExists(ctx context.Context, client *Client, database, table string) (bool, error)
- type ChMigrationOption
- type Client
- type ClientConfig
- type Repository
Constants ¶
const ( ErrEmptyHosts = utils.Error("empty hosts") ErrNilConfig = utils.Error("Nil Config") ErrInvalidCompression = utils.Error("invalid compression value") ErrInvalidDialTimeout = utils.Error("invalid dial timeout value") ErrInvalidMaxOpenConns = utils.Error("invalid max open connections value") ErrInvalidMaxIdleConns = utils.Error("invalid max idle connections value") ErrInvalidConnMaxLifetime = utils.Error("invalid connMaxLifetime value") ErrInvalidConnStrategy = utils.Error("invalid connStrategy value") CompressionLZ4 = "lz4" CompressionNone = "none" CompressionZSTD = "zstd" CompressionGZIP = "gzip" CompressionBrotli = "br" CompressionDeflate = "deflate" ConnSequential = "sequential" ConnRoundRobin = "roundRobin" )
const ( ErrNotSupported = utils.Error("method not supported") ErrInvalidParameters = utils.Error("invalid parameters") )
const (
MigrationTable = "db_migration"
)
Variables ¶
This section is empty.
Functions ¶
func ColumnExists ¶ added in v0.6.0
func ColumnExists(ctx context.Context, client *Client, database string, table string, column string) (bool, error)
ColumnExists check if a column exists
func CurrentDatabase ¶ added in v0.6.0
func DialectOptions ¶ added in v0.2.0
func DialectOptions() *goqu.SQLDialectOptions
func NewMigrationManager ¶ added in v0.4.2
func NewMigrationManager(ctx context.Context, client *Client, opts ...ChMigrationOption) (migrations.Manager, error)
Types ¶
type ChMigrationOption ¶ added in v0.6.0
type ChMigrationOption func(s *chMigrationManager) error
func WithCluster ¶ added in v0.6.0
func WithCluster(cluster string) ChMigrationOption
func WithModule ¶ added in v0.6.0
func WithModule(module string) ChMigrationOption
type Client ¶
type Client struct {
Conn clickhouse.Conn
Version *clickhouse.ServerVersion
}
func NewClient ¶
func NewClient(config *ClientConfig) (*Client, error)
func (*Client) NewRepository ¶ added in v0.4.0
func (c *Client) NewRepository(ctx context.Context, tableName string) Repository
NewRepository create a new repository
type ClientConfig ¶
type ClientConfig struct {
Hosts []string `json:"hosts"`
Database string `json:"database"`
Username string `json:"username"`
Debug bool `json:"debug"` //Debug true/false to enable debugging
Compression string `json:"compression"` // Compression algorithm: lz4, none
DialTimeout int `json:"dialTimeout"`
MaxOpenConns int `json:"maxOpenConns"`
MaxIdleConns int `json:"maxIdleConns"`
ConnMaxLifetime int `json:"connMaxLifetime"`
ConnStrategy string `json:"connStrategy"` // either sequential or roundRobin
BlockBufferSize uint8 `json:"blockBufferSize"`
Settings map[string]any `json:"settings"`
secure.DefaultCredentialConfig // optional password
tlsProvider.ClientConfig
}
func NewClientConfig ¶ added in v0.4.0
func NewClientConfig() *ClientConfig
func (ClientConfig) Validate ¶
func (c ClientConfig) Validate() error
type Repository ¶ added in v0.4.0
type Repository interface {
db.Identifier
db.Builder
db.Reader
db.Executor
db.Writer
db.Deleter
db.Counter
db.GridOps
Conn() clickhouse.Conn
}
func NewRepository ¶ added in v0.4.0
func NewRepository(ctx context.Context, conn clickhouse.Conn, tableName string) Repository