Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/controllers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use OpenRuntimes\Executor\Exception;
use OpenRuntimes\Executor\BodyMultipart;
use OpenRuntimes\Executor\Executor;
use OpenRuntimes\Executor\Runner\Adapter as Runner;
use Utopia\Logger\Log;
use Utopia\System\System;
Expand Down Expand Up @@ -166,7 +167,7 @@
->inject('response')
->inject('request')
->inject('log')
->inject('runner')
->inject('executor')
->action(
function (
string $runtimeId,
Expand All @@ -188,7 +189,7 @@ function (
Response $response,
Request $request,
Log $log,
Runner $runner
Executor $executor
) {
// Extra parsers and validators to support both JSON and multipart
$intParams = ['timeout', 'memory'];
Expand Down Expand Up @@ -241,7 +242,7 @@ function (

$variables = array_map(fn ($v) => strval($v), $variables);

$execution = $runner->createExecution(
$execution = $executor->createExecution(
$runtimeId,
$payload,
$path,
Expand Down
5 changes: 5 additions & 0 deletions app/http.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use OpenRuntimes\Executor\Executor;

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
Expand Down Expand Up @@ -30,9 +32,12 @@
Http::getEnv('OPR_EXECUTOR_DOCKER_HUB_PASSWORD', '')
));
$networks = explode(',', Http::getEnv('OPR_EXECUTOR_NETWORK') ?: 'openruntimes-runtimes');

$runner = new Docker($orchestration, $networks);
$executor = new Executor($runner);

Http::setResource('runner', fn () => $runner);
Http::setResource('executor', fn () => $executor);

$payloadSize = 22 * (1024 * 1024);
$settings = [
Expand Down
56 changes: 56 additions & 0 deletions src/Executor/Executor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace OpenRuntimes\Executor;

use OpenRuntimes\Executor\Runner\Adapter as Runner;
use Utopia\Logger\Log;

class Executor
{
public function __construct(
private readonly Runner $runner,
) {
}

public function createExecution(
string $runtimeId,
?string $payload,
string $path,
string $method,
mixed $headers,
int $timeout,
string $image,
string $source,
string $entrypoint,
mixed $variables,
float $cpus,
int $memory,
string $version,
string $runtimeEntrypoint,
bool $logging,
string $restartPolicy,
Log $log,
string $region = '',
): mixed {
return $this->runner->createExecution(
$runtimeId,
$payload,
$path,
$method,
$headers,
$timeout,
$image,
$source,
$entrypoint,
$variables,
$cpus,
$memory,
$version,
$runtimeEntrypoint,
$logging,
$restartPolicy,
$log,
$region,
);
}
}