Skip to content

Commit

Permalink
parseDSN: support connection pool settings (ClickHouse#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjm committed Sep 6, 2023
1 parent b0a69d7 commit 7ff140d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clickhouse_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,24 @@ func (o *Options) fromDSN(in string) error {
case "round_robin":
o.ConnOpenStrategy = ConnOpenRoundRobin
}
case "max_open_conns":
maxOpenConns, err := strconv.Atoi(params.Get(v))
if err != nil {
return errors.Wrap(err, "max_open_conns invalid value")
}
o.MaxOpenConns = maxOpenConns
case "max_idle_conns":
maxIdleConns, err := strconv.Atoi(params.Get(v))
if err != nil {
return errors.Wrap(err, "max_idle_conns invalid value")
}
o.MaxIdleConns = maxIdleConns
case "conn_max_lifetime":
connMaxLifetime, err := time.ParseDuration(params.Get(v))
if err != nil {
return errors.Wrap(err, "conn_max_lifetime invalid value")
}
o.ConnMaxLifetime = connMaxLifetime
case "username":
o.Auth.Username = params.Get(v)
case "password":
Expand Down

0 comments on commit 7ff140d

Please sign in to comment.