orbis/internal/persistence/connection.go
kjuulh e94271d5e2
All checks were successful
continuous-integration/drone/push Build is passing
feat: enable worker process
2025-01-17 21:28:23 +01:00

23 lines
424 B
Go

package persistence
import (
"context"
"fmt"
"os"
"time"
"github.com/jackc/pgx/v5/pgxpool"
)
func NewConnection() (*pgxpool.Pool, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
conn, err := pgxpool.New(ctx, os.Getenv("ORBIS_POSTGRES_DB"))
if err != nil {
return nil, fmt.Errorf("failed to connect to orbis postgres database: %w", err)
}
return conn, nil
}