-
Notifications
You must be signed in to change notification settings - Fork 3
/
dns.go
61 lines (57 loc) · 1.56 KB
/
dns.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package sql
import "github.com/abulo/ratel/v3/util"
func (c *Client) mysqlDns() string {
link := c.Username + ":" + c.Password + "@tcp(" + c.Host + ":" + c.Port + ")/" + c.Database + "?charset=" + c.Charset + "&loc=" + c.TimeZone
if c.ParseTime {
link = link + "&parseTime=true"
} else {
link = link + "&parseTime=false"
}
return link
}
func (c *Client) clickhouseDns() string {
link := "clickhouse://"
if !util.Empty(c.Username) {
link = link + c.Username
}
link = link + ":"
if !util.Empty(c.Password) {
link = link + c.Password
}
link = link + "@"
link = link + util.Implode(",", c.Addr)
link = link + "/"
if !util.Empty(c.Database) {
link = link + c.Database
}
param := make([]string, 0)
if !util.Empty(c.DialTimeout) {
param = append(param, "dial_timeout="+c.DialTimeout)
}
if !util.Empty(c.MaxExecutionTime) {
param = append(param, "max_execution_time="+c.MaxExecutionTime)
}
if !util.Empty(c.OpenStrategy) {
param = append(param, "connection_open_strategy="+c.OpenStrategy)
}
if c.Compress {
param = append(param, "compress=true")
} else {
param = append(param, "compress=false")
}
if !c.DisableDebug {
param = append(param, "debug=true")
} else {
param = append(param, "debug=false")
}
return link + "?" + util.Implode("&", param)
}
func (c *Client) postgresDns() string {
link := c.Username + ":" + c.Password + "@tcp(" + c.Host + ":" + c.Port + ")/" + c.Database + "?charset=" + c.Charset + "&loc=" + c.TimeZone
if c.ParseTime {
link = link + "&parseTime=true"
} else {
link = link + "&parseTime=false"
}
return link
}