ClickHouse / clickhouse-cpp

C++ client library for ClickHouse
Apache License 2.0
305 stars 159 forks source link

Multiple endpoints for connection. #310

Closed MikhailBurdukov closed 1 year ago

MikhailBurdukov commented 1 year ago

Specify multiple hosts for connection, to provide fault tolerance.

.SetHosts({ getEnvOrDefault("CLICKHOUSE_HOST",      "asasdasd"), 
                            getEnvOrDefault("CLICKHOUSE_HOST",      "localhost"),
                            getEnvOrDefault("CLICKHOUSE_HOST",      "noalocalhost"), 
                            getEnvOrDefault("CLICKHOUSE_HOST",      "localhost"), 
                           })

The endpoint is selecting according to EndpointsIterationAlgorithm, rn only RoundRobin approach is implemented.

Ref #139

MikhailBurdukov commented 1 year ago

In the last commit, a behavior was added that allows users to reset the connection to a connected endpoint, which is described here. I also checked manually that the client is trying to reconnect to the same endpoint using options_.send_retries, but I don't know how to implement this in the test, because as far as I understand, there are no tests that allow you to manipulate the connection or the `ClickHouse-server' directly. Does anyone have some ideas how to test such situation?

MikhailBurdukov commented 1 year ago

Discussed in direct messages:

All this is done in the last commit