mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch '1.7.x' into fix-github-check-urls
This commit is contained in:
commit
5df2f5ff80
4 changed files with 13 additions and 29 deletions
|
|
@ -251,7 +251,7 @@ CLI::setResource('logError', function (Registry $register) {
|
||||||
};
|
};
|
||||||
}, ['register']);
|
}, ['register']);
|
||||||
|
|
||||||
CLI::setResource('executor', fn () => new Executor(fn (string $projectId, string $deploymentId) => System::getEnv('_APP_EXECUTOR_HOST')));
|
CLI::setResource('executor', fn () => new Executor());
|
||||||
|
|
||||||
CLI::setResource('telemetry', fn () => new NoTelemetry());
|
CLI::setResource('telemetry', fn () => new NoTelemetry());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -880,7 +880,7 @@ App::setResource('apiKey', function (Request $request, Document $project): ?Key
|
||||||
return Key::decode($project, $key);
|
return Key::decode($project, $key);
|
||||||
}, ['request', 'project']);
|
}, ['request', 'project']);
|
||||||
|
|
||||||
App::setResource('executor', fn () => new Executor(fn (string $projectId, string $deploymentId) => System::getEnv('_APP_EXECUTOR_HOST')));
|
App::setResource('executor', fn () => new Executor());
|
||||||
|
|
||||||
App::setResource('resourceToken', function ($project, $dbForProject, $request) {
|
App::setResource('resourceToken', function ($project, $dbForProject, $request) {
|
||||||
$tokenJWT = $request->getParam('token');
|
$tokenJWT = $request->getParam('token');
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ Server::setResource('logError', function (Registry $register, Document $project)
|
||||||
};
|
};
|
||||||
}, ['register', 'project']);
|
}, ['register', 'project']);
|
||||||
|
|
||||||
Server::setResource('executor', fn () => new Executor(fn (string $projectId, string $deploymentId) => System::getEnv('_APP_EXECUTOR_HOST')));
|
Server::setResource('executor', fn () => new Executor());
|
||||||
|
|
||||||
$pools = $register->get('pools');
|
$pools = $register->get('pools');
|
||||||
$platform = new Appwrite();
|
$platform = new Appwrite();
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,14 @@ class Executor
|
||||||
public const METHOD_CONNECT = 'CONNECT';
|
public const METHOD_CONNECT = 'CONNECT';
|
||||||
public const METHOD_TRACE = 'TRACE';
|
public const METHOD_TRACE = 'TRACE';
|
||||||
|
|
||||||
private bool $selfSigned = false;
|
protected bool $selfSigned = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var callable(string, string): string $endpoint
|
|
||||||
*/
|
|
||||||
private $endpointSelector;
|
|
||||||
|
|
||||||
|
protected string $endpoint;
|
||||||
protected array $headers;
|
protected array $headers;
|
||||||
|
|
||||||
/**
|
public function __construct()
|
||||||
* @param callable(string, string): string $endpointSelector
|
|
||||||
*/
|
|
||||||
public function __construct(callable $endpointSelector)
|
|
||||||
{
|
{
|
||||||
$this->endpointSelector = $endpointSelector;
|
$this->endpoint = System::getEnv('_APP_EXECUTOR_HOST', '');
|
||||||
$this->headers = [
|
$this->headers = [
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'authorization' => 'Bearer ' . System::getEnv('_APP_EXECUTOR_SECRET', ''),
|
'authorization' => 'Bearer ' . System::getEnv('_APP_EXECUTOR_SECRET', ''),
|
||||||
|
|
@ -97,8 +90,8 @@ class Executor
|
||||||
'outputDirectory' => $outputDirectory
|
'outputDirectory' => $outputDirectory
|
||||||
];
|
];
|
||||||
|
|
||||||
$endpoint = $this->selectEndpoint($projectId, $deploymentId);
|
|
||||||
$response = $this->call($endpoint, self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
|
$response = $this->call($this->endpoint, self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
|
||||||
|
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
if ($status >= 400) {
|
if ($status >= 400) {
|
||||||
|
|
@ -128,8 +121,7 @@ class Executor
|
||||||
'timeout' => $timeout
|
'timeout' => $timeout
|
||||||
];
|
];
|
||||||
|
|
||||||
$endpoint = $this->selectEndpoint($projectId, $deploymentId);
|
$this->call($this->endpoint, self::METHOD_GET, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout, $callback);
|
||||||
$this->call($endpoint, self::METHOD_GET, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout, $callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -145,8 +137,7 @@ class Executor
|
||||||
$runtimeId = "$projectId-$deploymentId" . $suffix;
|
$runtimeId = "$projectId-$deploymentId" . $suffix;
|
||||||
$route = "/runtimes/$runtimeId";
|
$route = "/runtimes/$runtimeId";
|
||||||
|
|
||||||
$endpoint = $this->selectEndpoint($projectId, $deploymentId);
|
$response = $this->call($this->endpoint, self::METHOD_DELETE, $route, [
|
||||||
$response = $this->call($endpoint, self::METHOD_DELETE, $route, [
|
|
||||||
'x-opr-addressing-method' => 'broadcast'
|
'x-opr-addressing-method' => 'broadcast'
|
||||||
], [], true, 30);
|
], [], true, 30);
|
||||||
|
|
||||||
|
|
@ -239,8 +230,7 @@ class Executor
|
||||||
$requestTimeout = $timeout + 15;
|
$requestTimeout = $timeout + 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
$endpoint = $this->selectEndpoint($projectId, $deploymentId);
|
$response = $this->call($this->endpoint, self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId, 'content-type' => 'multipart/form-data', 'accept' => 'multipart/form-data' ], $params, true, $requestTimeout);
|
||||||
$response = $this->call($endpoint, self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId, 'content-type' => 'multipart/form-data', 'accept' => 'multipart/form-data' ], $params, true, $requestTimeout);
|
|
||||||
|
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
if ($status >= 400) {
|
if ($status >= 400) {
|
||||||
|
|
@ -274,8 +264,7 @@ class Executor
|
||||||
'timeout' => $timeout
|
'timeout' => $timeout
|
||||||
];
|
];
|
||||||
|
|
||||||
$endpoint = $this->selectEndpoint($projectId, $deploymentId);
|
$response = $this->call($this->endpoint, self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
|
||||||
$response = $this->call($endpoint, self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
|
|
||||||
|
|
||||||
$status = $response['headers']['status-code'];
|
$status = $response['headers']['status-code'];
|
||||||
if ($status >= 400) {
|
if ($status >= 400) {
|
||||||
|
|
@ -465,9 +454,4 @@ class Executor
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function selectEndpoint(string $projectId, string $deploymentId): string
|
|
||||||
{
|
|
||||||
return call_user_func($this->endpointSelector, $projectId, $deploymentId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue