Skip to content

Commit

Permalink
only ping a connection if immediately necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyzli committed Feb 28, 2025
1 parent 7e57e27 commit 523d6ff
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/sinks/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,13 @@ func NewClickHouse(cfg *ClickHouseConfig) (*ClickHouse, error) {
db.SetConnMaxIdleTime(time.Duration(*cfg.ConnMaxIdleTimeMs) * time.Millisecond)
}

err := db.Ping()
if err != nil {
return nil, err
}

if cfg.CreateTable {
err := db.Ping()
if err != nil {
return nil, err
}
var exists int
err := db.QueryRow(fmt.Sprintf("EXISTS %s", cfg.TableName)).Scan(&exists)
err = db.QueryRow(fmt.Sprintf("EXISTS %s", cfg.TableName)).Scan(&exists)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 523d6ff

Please sign in to comment.