From 06448bbdc50b217250a729264c0888b8b724ee4a Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Thu, 24 Feb 2022 12:58:10 +0000 Subject: [PATCH] Remove Synchronous execution model --- app/controllers/api/functions.php | 13 ++++- src/Appwrite/Utopia/Response.php | 1 - .../Utopia/Response/Model/SyncExecution.php | 53 ------------------- 3 files changed, 11 insertions(+), 56 deletions(-) delete mode 100644 src/Appwrite/Utopia/Response/Model/SyncExecution.php diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 075dfc649..91c8aeda2 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -967,11 +967,20 @@ App::post('/v1/functions/:functionId/executions') } Authorization::skip(fn() => $dbForProject->updateDocument('executions', $executionId, $execution)); - $executionResponse['response'] = ($executionResponse['status'] !== 'completed') ? $executionResponse['stderr'] : $executionResponse['stdout']; + + $executionResponse['$id'] = $executionId; + $executionResponse['$read'] = $execution->getAttribute('$read', []); + $executionResponse['$write'] = $execution->getAttribute('$write', []); + $executionResponse['functionId'] = $function->getId(); + $executionResponse['dateCreated'] = $execution->getAttribute('dateCreated'); + $executionResponse['trigger'] = $execution->getAttribute('trigger'); + $executionResponse['status'] = $execution->getAttribute('status'); + $executionResponse['statusCode'] = $execution->getAttribute('statusCode'); + $executionResponse['time'] = $execution->getAttribute('time'); $response ->setStatusCode(Response::STATUS_CODE_CREATED) - ->dynamic(new Document($executionResponse), Response::MODEL_SYNC_EXECUTION); + ->dynamic(new Document($executionResponse), Response::MODEL_EXECUTION); }); App::get('/v1/functions/:functionId/executions') diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 32375af35..2cfe7f7ef 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -156,7 +156,6 @@ class Response extends SwooleResponse const MODEL_DEPLOYMENT = 'deployment'; const MODEL_DEPLOYMENT_LIST = 'deploymentList'; const MODEL_EXECUTION = 'execution'; - const MODEL_SYNC_EXECUTION = 'syncExecution'; const MODEL_EXECUTION_LIST = 'executionList'; const MODEL_BUILD = 'build'; const MODEL_BUILD_LIST = 'buildList'; diff --git a/src/Appwrite/Utopia/Response/Model/SyncExecution.php b/src/Appwrite/Utopia/Response/Model/SyncExecution.php deleted file mode 100644 index 05220f78f..000000000 --- a/src/Appwrite/Utopia/Response/Model/SyncExecution.php +++ /dev/null @@ -1,53 +0,0 @@ -addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Execution Status.', - 'default' => '', - 'example' => 'completed', - ]) - ->addRule('response', [ - 'type' => self::TYPE_STRING, - 'description' => 'Execution Response.', - 'default' => '', - 'example' => 'Hello World!', - ]) - ->addRule('time', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Execution Time.', - 'default' => 0, - 'example' => 100, - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'Syncronous Execution'; - } - - /** - * Get Collection - * - * @return string - */ - public function getType():string - { - return Response::MODEL_SYNC_EXECUTION; - } -} \ No newline at end of file