From 7ff140d7dba5a6e3222469f7422dc65a5210f44a Mon Sep 17 00:00:00 2001 From: Jimmie Han Date: Wed, 6 Sep 2023 20:27:17 +0800 Subject: [PATCH] parseDSN: support connection pool settings (#1082) --- clickhouse_options.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/clickhouse_options.go b/clickhouse_options.go index f9ddcb343d..1aef8194df 100644 --- a/clickhouse_options.go +++ b/clickhouse_options.go @@ -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":