go-clickhouse
go-clickhouse copied to clipboard
Multihost configuration for CH clusters
Hi, official Clickhouse API support multiple hosts connection. It helps to evenly distribute load in cluster setup. As I understood this is no such option in this library. Do you plan on support it?
Hey,
In Uptrace we have a set of utility functions that pick up a random CH node, e.g.
func randCH() *ch.DB {}
randCH().NewSelect().Model(...).Scan(ctx)
I would recommend doing the same if you need to balance the load.
where can i find this in code? i didn't find randCH() method of db .
Addr is single host in the struct. Cluster is using for only auto migrating tools.
type Config struct {
chpool.Config
Compression bool
Addr string
User string
Password string
Database string
Cluster string
DialTimeout time.Duration
TLSConfig *tls.Config
QuerySettings map[string]any
ReadTimeout time.Duration
WriteTimeout time.Duration
MaxRetries int
MinRetryBackoff time.Duration
MaxRetryBackoff time.Duration
}`