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

Function ParseDSN

client/config.go:87–111  ·  view source on GitHub ↗

ParseDSN parse the DSN string to a Config.

(dsn string)

Source from the content-addressed store, hash-verified

85
86// ParseDSN parse the DSN string to a Config.
87func ParseDSN(dsn string) (cfg *Config, err error) {
88 if !strings.HasPrefix(dsn, DBScheme) && !strings.HasPrefix(dsn, DBSchemeAlias) {
89 dsn = DBScheme + "://" + dsn
90 }
91
92 var u *url.URL
93 if u, err = url.Parse(dsn); err != nil {
94 return nil, err
95 }
96
97 cfg = NewConfig()
98 cfg.DatabaseID = u.Host
99
100 q := u.Query()
101 // option: use_leader, use_follower
102 cfg.UseLeader, _ = strconv.ParseBool(q.Get(paramUseLeader))
103 cfg.UseFollower, _ = strconv.ParseBool(q.Get(paramUseFollower))
104 if !cfg.UseLeader && !cfg.UseFollower {
105 cfg.UseLeader = true
106 }
107 cfg.Mirror = q.Get(paramMirror)
108 cfg.UseDirectRPC, _ = strconv.ParseBool(q.Get(paramUseDirectRPC))
109
110 return cfg, nil
111}

Callers 14

TestFullProcessFunction · 0.92
CreateMethod · 0.92
TestFullProcessFunction · 0.92
showDatabaseDepositFunction · 0.92
runMirrorFunction · 0.92
runDropFunction · 0.92
mainFunction · 0.92
TestFullProcessFunction · 0.92
benchMinerFunction · 0.92
TestConfigFunction · 0.85
OpenMethod · 0.85
WaitDBCreationFunction · 0.85

Calls 3

NewConfigFunction · 0.85
QueryMethod · 0.65
GetMethod · 0.65

Tested by 6

TestFullProcessFunction · 0.74
TestFullProcessFunction · 0.74
TestFullProcessFunction · 0.74
benchMinerFunction · 0.74
TestConfigFunction · 0.68
TestCreateFunction · 0.68