fix: db queues

This commit is contained in:
loks0n 2025-09-12 10:07:40 +01:00
parent 918912c0b9
commit 39a190f60c
2 changed files with 12 additions and 9 deletions

View file

@ -538,7 +538,7 @@ App::get('/v1/health/queue/databases')
->inject('response')
->action(function (string $name, int|string $threshold, Database $queueForDatabase, Response $response) {
$threshold = \intval($threshold);
$size = $queueForDatabase->getSize();
$size = $queueForDatabase->setQueue($name)->getSize();
if ($size >= $threshold) {
throw new Exception(Exception::HEALTH_QUEUE_SIZE_EXCEEDED, "Queue size threshold hit. Current size is {$size} and threshold is {$threshold}.");

View file

@ -161,17 +161,20 @@ class Database extends Event
return $this->document;
}
public function getQueue(): string
public function setProject(Document $project): self
{
try {
$dsn = new DSN($this->getProject()->getAttribute('database'));
} catch (\InvalidArgumentException) {
// TODO: Temporary until all projects are using shared tables
$dsn = new DSN('mysql://' . $this->getProject()->getAttribute('database'));
$database = $project->getAttribute('database');
if (!empty($database)) {
try {
$dsn = new DSN($database);
} catch (\InvalidArgumentException) {
// TODO: Temporary until all projects are using shared tables
$dsn = new DSN("mysql://$database");
}
$this->queue = $dsn->getHost();
}
$this->queue = $dsn->getHost();
return $this->queue;
return parent::setProject($project);
}
/**