pool

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAll

func CloseAll()

CloseAll closed all connection and destroys the pool

func FreeClusterConn

func FreeClusterConn()

func InitClusterConn

func InitClusterConn(chCfg *config.ClickHouseConfig) (err error)

Each shard has a pool.Conn which connects to one replica inside the shard. We need more control than replica single-point-failure.

func NumShard

func NumShard() (cnt int)

Types

type Conn added in v0.5.0

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

func (*Conn) AsyncInsert added in v0.7.0

func (c *Conn) AsyncInsert(query string, wait bool) error

func (*Conn) Close added in v0.5.0

func (c *Conn) Close() error

func (*Conn) Exec added in v0.5.0

func (c *Conn) Exec(query string, args ...any) error

func (*Conn) Ping added in v0.5.0

func (c *Conn) Ping() error

func (*Conn) Query added in v0.5.0

func (c *Conn) Query(query string, args ...any) (*Rows, error)

func (*Conn) QueryRow added in v0.5.0

func (c *Conn) QueryRow(query string, args ...any) *Row

func (*Conn) Write added in v0.5.0

func (c *Conn) Write(prepareSQL string, rows model.Rows, idxBegin, idxEnd int) (numBad int, err error)

type Row added in v0.5.0

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

func (*Row) Scan added in v0.5.0

func (r *Row) Scan(dest ...any) error

type Rows added in v0.5.0

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

func (*Rows) Close added in v0.5.0

func (r *Rows) Close() error

func (*Rows) Columns added in v0.5.0

func (r *Rows) Columns() ([]string, error)

func (*Rows) Next added in v0.5.0

func (r *Rows) Next() bool

func (*Rows) Scan added in v0.5.0

func (r *Rows) Scan(dest ...any) error

type ShardConn

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

ShardConn a datastructure for storing the clickhouse connection

func GetShardConn

func GetShardConn(batchNum int64) (sc *ShardConn)

GetShardConn select a clickhouse shard based on batchNum

func (*ShardConn) Close

func (sc *ShardConn) Close()

Close closes the current replica connection

func (*ShardConn) GetReplica

func (sc *ShardConn) GetReplica() (replica string)

GetReplica returns the replica to which db connects

func (*ShardConn) NextGoodReplica

func (sc *ShardConn) NextGoodReplica(ctx context.Context, failedVer int) (db *Conn, dbVer int, err error)

NextGoodReplica connects to next good replica

func (*ShardConn) SubmitTask added in v0.5.0

func (sc *ShardConn) SubmitTask(fn func()) (err error)

Jump to

Keyboard shortcuts

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