Skip to content

Commit 06b3ca7

Browse files
committed
Add Protocol support for ConnectionConfig
1 parent 5797ebd commit 06b3ca7

25 files changed

Lines changed: 89 additions & 39 deletions

adapters/clickhouse_adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

adapters/mysql_adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

adapters/postgresql_adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

check_parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

checks_cfg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cnn/clickhouse_cnn.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,24 +15,41 @@
1515
package cnn
1616

1717
import (
18+
"crypto/tls"
19+
1820
"github.com/ClickHouse/clickhouse-go/v2"
1921
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
2022
"github.com/DataBridgeTech/dbqcore"
2123
)
2224

2325
func NewClickhouseConnection(connectionCfg dbqcore.ConnectionConfig, poolSize int) (driver.Conn, error) {
26+
proto, tlsCfg := clickhouseProtocol(connectionCfg.Protocol)
27+
2428
cnn, err := clickhouse.Open(&clickhouse.Options{
2529
Addr: []string{connectionCfg.Host},
2630
Auth: clickhouse.Auth{
2731
Database: connectionCfg.Database,
2832
Username: connectionCfg.Username,
2933
Password: connectionCfg.Password,
3034
},
35+
Protocol: proto,
36+
TLS: tlsCfg,
3137
MaxOpenConns: poolSize,
3238
MaxIdleConns: poolSize,
33-
//TLS: &tls.Config{
34-
// InsecureSkipVerify: true,
35-
//},
3639
})
3740
return cnn, err
3841
}
42+
43+
func clickhouseProtocol(protocol string) (clickhouse.Protocol, *tls.Config) {
44+
switch protocol {
45+
case "http":
46+
return clickhouse.HTTP, nil
47+
case "https":
48+
return clickhouse.HTTP, &tls.Config{}
49+
case "clickhouse-secure":
50+
return clickhouse.Native, &tls.Config{}
51+
default:
52+
// "clickhouse", "" or any unrecognised value → native TCP, no TLS
53+
return clickhouse.Native, nil
54+
}
55+
}

cnn/mysql_cnn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cnn/postgresql_cnn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

connectors/clickhouse_connector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

connectors/mysql_connector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2025 The DBQ Authors
1+
// Copyright 2026 The DBQ Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)