Merge pull request #9850 from appwrite/task-coroutine-hooks-1.6

fix: task coroutine hooks
This commit is contained in:
Christy Jacob 2025-05-21 18:31:57 +04:00 committed by GitHub
commit 02de47f1dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 15 deletions

View file

@ -284,6 +284,5 @@ $cli
$cli->shutdown()->action(fn () => Timer::clearAll());
// Enable coroutines, but disable TCP hooks. These don't work until we use `\Utopia\Cache\Adapter\Pool` and `\Utopia\Database\Adapter\Pool`.
Runtime::enableCoroutine(SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_TCP);
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
run($cli->run(...));

12
composer.lock generated
View file

@ -4771,16 +4771,16 @@
"packages-dev": [
{
"name": "appwrite/sdk-generator",
"version": "0.40.17",
"version": "0.40.18",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-generator.git",
"reference": "7e333c1003bfd4763e4d6f3a0a799fde5e7bc4de"
"reference": "38de4b9c58112d7e83eb75955994c8412a401093"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/7e333c1003bfd4763e4d6f3a0a799fde5e7bc4de",
"reference": "7e333c1003bfd4763e4d6f3a0a799fde5e7bc4de",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/38de4b9c58112d7e83eb75955994c8412a401093",
"reference": "38de4b9c58112d7e83eb75955994c8412a401093",
"shasum": ""
},
"require": {
@ -4816,9 +4816,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": {
"issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/0.40.17"
"source": "https://github.com/appwrite/sdk-generator/tree/0.40.18"
},
"time": "2025-05-16T15:10:54+00:00"
"time": "2025-05-21T14:14:47+00:00"
},
{
"name": "doctrine/annotations",

View file

@ -79,16 +79,16 @@ abstract class ScheduleBase extends Action
// start with "0" to load all active documents.
$lastSyncUpdate = "0";
$this->collectSchedules($pools, $dbForPlatform, $getProjectDB, $lastSyncUpdate);
$this->collectSchedules($dbForPlatform, $getProjectDB, $lastSyncUpdate);
Console::success("Starting timers at " . DateTime::now());
/**
* The timer synchronize $schedules copy with database collection.
*/
Timer::tick(static::UPDATE_TIMER * 1000, function () use ($pools, $dbForPlatform, $getProjectDB, &$lastSyncUpdate) {
Timer::tick(static::UPDATE_TIMER * 1000, function () use ($dbForPlatform, $getProjectDB, &$lastSyncUpdate) {
$time = DateTime::now();
Console::log("Sync tick: Running at $time");
$this->collectSchedules($pools, $dbForPlatform, $getProjectDB, $lastSyncUpdate);
$this->collectSchedules($dbForPlatform, $getProjectDB, $lastSyncUpdate);
});
while (true) {
@ -103,7 +103,7 @@ abstract class ScheduleBase extends Action
}
}
private function collectSchedules(Group $pools, Database $dbForPlatform, callable $getProjectDB, string &$lastSyncUpdate): void
private function collectSchedules(Database $dbForPlatform, callable $getProjectDB, string &$lastSyncUpdate): void
{
// If we haven't synced yet, load all active schedules
$initialLoad = $lastSyncUpdate === "0";
@ -115,7 +115,7 @@ abstract class ScheduleBase extends Action
* @throws Exception
* @var Document $schedule
*/
$getSchedule = function (Document $schedule) use ($pools, $dbForPlatform, $getProjectDB): array {
$getSchedule = function (Document $schedule) use ($dbForPlatform, $getProjectDB): array {
$project = $dbForPlatform->getDocument('projects', $schedule->getAttribute('projectId'));
$resource = $getProjectDB($project)->getDocument(

View file

@ -76,7 +76,7 @@ class ScheduleFunctions extends ScheduleBase
}
foreach ($delayedExecutions as $delay => $schedules) {
\go(function () use ($delay, $schedules, $pools, $dbForPlatform) {
\go(function () use ($delay, $schedules, $dbForPlatform) {
\sleep($delay); // in seconds
foreach ($schedules as $delayConfig) {

View file

@ -40,7 +40,7 @@ class ScheduleMessages extends ScheduleBase
continue;
}
\go(function () use ($schedule, $scheduledAt, $pools, $dbForPlatform) {
\go(function () use ($schedule, $scheduledAt, $dbForPlatform) {
$queueForMessaging = new Messaging($this->publisher);
$this->updateProjectAccess($schedule['project'], $dbForPlatform);