1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00

use config

This commit is contained in:
Annika Hannig
2022-01-12 15:31:02 +01:00
parent 5419f5cd58
commit f9584e711a
2 changed files with 4 additions and 15 deletions

View File

@ -2,28 +2,16 @@ package postgres
import (
"context"
"errors"
"os"
"path/filepath"
"github.com/alice-lg/alice-lg/pkg/config"
"github.com/jackc/pgx/v4/pgxpool"
)
var (
// ErrMaxConnsUnconfigured will be returned, if the
// the maximum connections are zero.
ErrMaxConnsUnconfigured = errors.New("MaxConns not configured")
)
// ConnectOpts database connection options
type ConnectOpts struct {
URL string
MaxConns int32
MinConns int32
}
// Connect creates and configures a pgx pool
func Connect(ctx context.Context, opts *ConnectOpts) (*pgxpool.Pool, error) {
func Connect(ctx context.Context, opts *config.PostgresConfig) (*pgxpool.Pool, error) {
// Initialize postgres connection
cfg, err := pgxpool.ParseConfig(opts.URL)
if err != nil {

View File

@ -4,6 +4,7 @@ import (
"context"
"github.com/alice-lg/alice-lg/pkg/api"
"github.com/jackc/pgx/v4/pgxpool"
)