Ensure heartbeat is cleared on destruct

This commit is contained in:
Jake Barnby 2025-06-25 14:52:14 -04:00
parent e37cea5146
commit 255be3babf
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 22 additions and 1 deletions

View file

@ -54,6 +54,16 @@ class Database extends Event
return $this;
}
/**
* Returns set database for this event.
*
* @return null|Document
*/
public function getDatabase(): ?Document
{
return $this->database;
}
/**
* Set the collection for this database event.
*

View file

@ -21,6 +21,8 @@ use Utopia\Queue\Message;
class Databases extends Action
{
private ?int $heartbeatId = null;
public static function getName(): string
{
return 'databases';
@ -41,11 +43,19 @@ class Databases extends Action
->inject('log')
->callback($this->action(...));
Timer::tick(10_000, function () {
$this->heartbeatId = Timer::tick(10_000, function () {
Console::info('Databases worker heartbeat');
});
}
public function __destruct()
{
if ($this->heartbeatId) {
Timer::clear($this->heartbeatId);
$this->heartbeatId = null;
}
}
/**
* @param Message $message
* @param Document $project
@ -137,6 +147,7 @@ class Databases extends Action
$projectId = $project->getId();
$event = "databases.[databaseId].collections.[collectionId].attributes.[attributeId].update";
/**
* TODO @christyjacob4 verify if this is still the case
* Fetch attribute from the database, since with Resque float values are loosing informations.