pool

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 8 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(hosts [][]string, port int, db, username, password, dsnParams string, secure, skipVerify bool, maxOpenConns int) (err error)

Each shard has a clickhouse.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 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(failedVer int) (db clickhouse.Conn, dbVer int, err error)

NextGoodReplica connects to next good replica

Jump to

Keyboard shortcuts

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