MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / FormatDSN

Method FormatDSN

client/config.go:59–84  ·  view source on GitHub ↗

FormatDSN formats the given Config into a DSN string which can be passed to the driver.

()

Source from the content-addressed store, hash-verified

57
58// FormatDSN formats the given Config into a DSN string which can be passed to the driver.
59func (cfg *Config) FormatDSN() string {
60 // build query from arguments
61
62 u := &url.URL{
63 Scheme: DBScheme,
64 Host: cfg.DatabaseID,
65 }
66
67 newQuery := u.Query()
68 if cfg.UseFollower {
69 newQuery.Add(paramUseFollower, strconv.FormatBool(cfg.UseFollower))
70
71 if cfg.UseLeader {
72 newQuery.Add(paramUseLeader, strconv.FormatBool(cfg.UseLeader))
73 }
74 }
75 if cfg.Mirror != "" {
76 newQuery.Add(paramMirror, cfg.Mirror)
77 }
78 if cfg.UseDirectRPC {
79 newQuery.Add(paramUseDirectRPC, strconv.FormatBool(cfg.UseDirectRPC))
80 }
81 u.RawQuery = newQuery.Encode()
82
83 return u.String()
84}
85
86// ParseDSN parse the DSN string to a Config.
87func ParseDSN(dsn string) (cfg *Config, err error) {

Callers 11

CreateFunction · 0.95
DropMethod · 0.95
getConnMethod · 0.95
UseDBMethod · 0.95
NewDatabaseFunction · 0.95
NewExchangeFunction · 0.95
TestConfigFunction · 0.80
TestFullProcessFunction · 0.80
mainFunction · 0.80
TestFullProcessFunction · 0.80
benchMinerFunction · 0.80

Calls 3

QueryMethod · 0.65
AddMethod · 0.45
StringMethod · 0.45

Tested by 4

TestConfigFunction · 0.64
TestFullProcessFunction · 0.64
TestFullProcessFunction · 0.64
benchMinerFunction · 0.64