diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index d2f70dddf2..838870345a 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -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. * diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index fb0a4497aa..0ba55ad97f 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -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.