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

fix: support multi clickhouse addrs #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion storage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ type Configuration struct {
MaxSpanCount int `yaml:"max_span_count"`
// Encoding either json or protobuf. Default is json.
Encoding EncodingType `yaml:"encoding"`
// ClickHouse address e.g. localhost:9000.
// ClickHouse address
// e.g. single addr: localhost:9000 multi addrs: 10.10.1.1:9000,10.10.1.2:9001
Address string `yaml:"address"`
// Directory with .sql files to run at plugin startup, mainly for integration tests.
// Depending on the value of init_tables, this can be run as a
Expand Down
6 changes: 5 additions & 1 deletion storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ func NewStore(logger hclog.Logger, cfg Configuration) (*Store, error) {
func connector(cfg Configuration) (*sql.DB, error) {
var conn *sql.DB

var addrs []string
for _, addr := range strings.Split(cfg.Address, ",") {
addrs = append(addrs, sanitize(addr))
}
options := clickhouse.Options{
Addr: []string{sanitize(cfg.Address)},
Addr: addrs,
Auth: clickhouse.Auth{
Database: cfg.Database,
Username: cfg.Username,
Expand Down