fix: Gitea Traefik routing and connection pool optimization
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
- Remove middleware reference from Gitea Traefik labels (caused routing issues) - Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s) - Add explicit service reference in Traefik labels - Fix intermittent 504 timeouts by improving PostgreSQL connection handling Fixes Gitea unreachability via git.michaelschiemer.de
This commit is contained in:
107
src/Framework/Database/Browser/Discovery/TableDiscovery.php
Normal file
107
src/Framework/Database/Browser/Discovery/TableDiscovery.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Database\Browser\Discovery;
|
||||
|
||||
use App\Framework\Database\Browser\ValueObjects\TableMetadata;
|
||||
use App\Framework\Database\ConnectionInterface;
|
||||
use App\Framework\Database\ValueObjects\SqlQuery;
|
||||
|
||||
final readonly class TableDiscovery
|
||||
{
|
||||
public function __construct(
|
||||
private ConnectionInterface $connection
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover all tables in the current database
|
||||
*
|
||||
* @return array<TableMetadata>
|
||||
*/
|
||||
public function discoverAllTables(): array
|
||||
{
|
||||
$databaseName = $this->getCurrentDatabase();
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
table_name,
|
||||
table_rows,
|
||||
ROUND((data_length + index_length) / 1024 / 1024, 2) as size_mb,
|
||||
engine,
|
||||
table_collation
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = ?
|
||||
AND table_type = 'BASE TABLE'
|
||||
ORDER BY table_name
|
||||
";
|
||||
|
||||
$query = SqlQuery::create($sql, [$databaseName]);
|
||||
$result = $this->connection->query($query);
|
||||
$tables = $result->fetchAll();
|
||||
|
||||
$tableMetadata = [];
|
||||
foreach ($tables as $tableData) {
|
||||
$tableMetadata[] = new TableMetadata(
|
||||
name: $tableData['table_name'],
|
||||
rowCount: isset($tableData['table_rows']) ? (int) $tableData['table_rows'] : null,
|
||||
sizeMb: isset($tableData['size_mb']) ? (float) $tableData['size_mb'] : null,
|
||||
engine: $tableData['engine'] ?? null,
|
||||
collation: $tableData['table_collation'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
return $tableMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover a specific table by name
|
||||
*/
|
||||
public function discoverTable(string $tableName): ?TableMetadata
|
||||
{
|
||||
$databaseName = $this->getCurrentDatabase();
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
table_name,
|
||||
table_rows,
|
||||
ROUND((data_length + index_length) / 1024 / 1024, 2) as size_mb,
|
||||
engine,
|
||||
table_collation
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = ?
|
||||
AND table_name = ?
|
||||
";
|
||||
|
||||
$query = SqlQuery::create($sql, [$databaseName, $tableName]);
|
||||
$result = $this->connection->query($query);
|
||||
$row = $result->fetch();
|
||||
|
||||
if ($row === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TableMetadata(
|
||||
name: $row['table_name'],
|
||||
rowCount: isset($row['table_rows']) ? (int) $row['table_rows'] : null,
|
||||
sizeMb: isset($row['size_mb']) ? (float) $row['size_mb'] : null,
|
||||
engine: $row['engine'] ?? null,
|
||||
collation: $row['table_collation'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current database name
|
||||
*/
|
||||
private function getCurrentDatabase(): string
|
||||
{
|
||||
$sql = "SELECT DATABASE() as db";
|
||||
$query = SqlQuery::create($sql, []);
|
||||
$result = $this->connection->query($query);
|
||||
$row = $result->fetch();
|
||||
|
||||
return $row['db'] ?? 'unknown';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user