aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/config.go b/config.go
index 6261eb2..883b41f 100644
--- a/config.go
+++ b/config.go
@@ -2,11 +2,18 @@ package main
import (
"bufio"
+ "context"
+ "errors"
"os"
+ "github.com/jackc/pgx/v5/pgxpool"
"go.lindenii.runxiyu.org/lindenii-common/scfg"
)
+var database *pgxpool.Pool
+
+var err_unsupported_database_type = errors.New("Unsupported database type")
+
var config struct {
HTTP struct {
Net string `scfg:"net"`
@@ -33,5 +40,13 @@ func load_config(path string) (err error) {
return err
}
+ if config.DB.Type != "postgres" {
+ return err_unsupported_database_type
+ }
+ database, err = pgxpool.New(context.Background(), config.DB.Conn)
+ if err != nil {
+ return err
+ }
+
return nil
}