Skip to content

Commit

Permalink
update: support tls and native protocol for higher level driver when …
Browse files Browse the repository at this point in the history
…url is from clickhouse.cloud
  • Loading branch information
riccardo-gnosis committed Aug 30, 2024
1 parent 675f6d9 commit c92e396
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/db/high_level_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package db

import (
"context"
"crypto/tls"

"fmt"
"net"
Expand Down Expand Up @@ -48,7 +49,7 @@ func ParseChUrlIntoOptionsHighLevel(url string) clickhouse.Options {
password = strings.Split(credentials, ":")[1]

var dialCount int
return clickhouse.Options{
options := clickhouse.Options{
Addr: []string{fqdn},
Auth: clickhouse.Auth{
Database: database,
Expand Down Expand Up @@ -85,6 +86,12 @@ func ParseChUrlIntoOptionsHighLevel(url string) clickhouse.Options {
{Name: utils.CliName, Version: utils.Version},
},
}}
if strings.Contains(fqdn, "clickhouse.cloud") {
options.Addr = []string{fmt.Sprintf("https://%s", fqdn)}
options.Protocol = clickhouse.Native
options.TLS = &tls.Config{}
}
return options
}

func (p *DBService) Delete(obj DeletableObject) error {
Expand Down

0 comments on commit c92e396

Please sign in to comment.