1
0
Fork 0
mirror of synced 2024-06-26 18:20:43 +12:00

Added function trigger

This commit is contained in:
Eldad Fux 2020-07-23 08:52:03 +03:00
parent 3c44747cae
commit 4a9f0a5ebb
4 changed files with 21 additions and 10 deletions

View file

@ -1395,6 +1395,15 @@ $collections = [
'required' => false,
'array' => false,
],
[
'$collection' => Database::SYSTEM_COLLECTION_RULES,
'label' => 'Trigger',
'key' => 'trigger',
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
'default' => '',
'required' => false,
'array' => false,
],
[
'$collection' => Database::SYSTEM_COLLECTION_RULES,
'label' => 'Exit Code',

View file

@ -564,6 +564,7 @@ App::post('/v1/functions/:functionId/executions')
'dateCreated' => time(),
'functionId' => $function->getId(),
'status' => 'waiting', // waiting / processing / completed / failed
'trigger' => 'http', // http / schedule / event
'exitCode' => 0,
'stdout' => '',
'stderr' => '',
@ -581,7 +582,7 @@ App::post('/v1/functions/:functionId/executions')
'functionId' => $function->getId(),
'executionId' => $execution->getId(),
'functionTag' => $tag->getId(),
'functionTrigger' => 'API',
'functionTrigger' => 'http',
]);
}

View file

@ -282,9 +282,10 @@ $timeout = $this->getParam('timeout', 900);
<thead>
<tr>
<th width="30"></th>
<th width="170">Triggered</th>
<th width="160">Created</th>
<th width="150">Status</th>
<th width="100">Runtime</th>
<th width="120">Trigger</th>
<th width="80">Runtime</th>
<th></th>
</tr>
</thead>
@ -303,6 +304,9 @@ $timeout = $this->getParam('timeout', 900);
<span data-ls-bind="{{execution.status}}"></span>
<span class="text-fade text-size-small" data-ls-if="{{execution.exitCode}} !== 0" data-ls-bind=" exit code: {{execution.exitCode}}"></span>
</td>
<td data-title="Trigger: ">
<span data-ls-bind="{{execution.trigger}}"></span>
</td>
<td data-title="Runtime: ">
<span data-ls-if="{{execution.status}} === 'completed' || {{execution.status}} === 'failed'" data-ls-bind="{{execution.time|seconds2hum}}"></span>
<span data-ls-if="{{execution.status}} === 'waiting' || {{execution.status}} === 'processing'">-</span>

View file

@ -71,8 +71,8 @@ Console::success('Finished warmup in '.$warmupTime.' seconds');
* + pass one-time api key
* 4. Update execution status - DONE
* 5. Update execution stdout & stderr - DONE
* 6. Trigger audit log
* 7. Trigger usage log
* 6. Trigger audit log - DONE
* 7. Trigger usage log - DONE
*/
//TODO aviod scheduled execution if delay is bigger than X offest
@ -90,13 +90,10 @@ Console::success('Finished warmup in '.$warmupTime.' seconds');
/**
* Get Usage Stats
* -> Network (docker stats --no-stream --format="{{.NetIO}}" appwrite)
* -> CPU Time
* -> Invoctions (+1)
* Report to usage worker
* -> CPU Time - DONE
* -> Invoctions (+1) - DONE
*/
// Double-check Cleanup
class FunctionsV1
{
public $args = [];