dbjobqueue: add settings for max pool connections
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
f4412ff07f
commit
c6fbf589aa
2 changed files with 23 additions and 1 deletions
|
|
@ -15,6 +15,8 @@ import (
|
|||
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/auth"
|
||||
"github.com/osbuild/osbuild-composer/internal/cloudapi"
|
||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||
|
|
@ -25,7 +27,6 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/weldr"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type Composer struct {
|
||||
|
|
@ -77,6 +78,11 @@ func NewComposer(config *ComposerConfigFile, stateDir, cacheDir string) (*Compos
|
|||
config.Worker.PGDatabase,
|
||||
config.Worker.PGSSLMode,
|
||||
)
|
||||
|
||||
if config.Worker.PGMaxConns > 0 {
|
||||
dbURL += fmt.Sprintf("&pool_max_conns=%d", config.Worker.PGMaxConns)
|
||||
}
|
||||
|
||||
jobs, err = dbjobqueue.New(dbURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot create jobqueue: %v", err)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
|
@ -44,6 +45,7 @@ type WorkerAPIConfig struct {
|
|||
PGUser string `toml:"pg_user" env:"PGUSER"`
|
||||
PGPassword string `toml:"pg_password" env:"PGPASSWORD"`
|
||||
PGSSLMode string `toml:"pg_ssl_mode" env:"PGSSLMODE"`
|
||||
PGMaxConns int `toml:"pg_max_conns" env:"PGMAXCONNS"`
|
||||
EnableTLS bool `toml:"enable_tls"`
|
||||
EnableMTLS bool `toml:"enable_mtls"`
|
||||
EnableJWT bool `toml:"enable_jwt"`
|
||||
|
|
@ -143,6 +145,20 @@ func loadConfigFromEnv(intf interface{}) error {
|
|||
continue
|
||||
}
|
||||
fieldV.SetString(confV)
|
||||
case reflect.Int:
|
||||
key, ok := fieldT.Tag.Lookup("env")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
confV, ok := os.LookupEnv(key)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
value, err := strconv.ParseInt(confV, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fieldV.SetInt(value)
|
||||
case reflect.Bool:
|
||||
// no-op
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue