Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multihost configuration for CH clusters #58

Open
Termina1 opened this issue Feb 21, 2023 · 2 comments
Open

Multihost configuration for CH clusters #58

Termina1 opened this issue Feb 21, 2023 · 2 comments

Comments

@Termina1
Copy link

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?

@vmihailenco
Copy link
Member

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.

@vortex14
Copy link

vortex14 commented Sep 20, 2024

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
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants