Rename the Deployments service to Deployment\Backend

Backend says what the abstraction is — a swappable build-dispatch
backend — and Orchestrator names the jobs-service strategy after the
system it talks to, freeing 'Jobs' for the worker that consumes its
callbacks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
loks0nandClaude Fable 5 committed 2026-07-14 14:05:13 +01:00
1 parent 35c67a72cc
commit 2fb04a7bdc
19 files changed
+57 -57

No files matched your search

+7 -5
View File
@@ -5,6 +5,8 @@ use Ahc\Jwt\JWTException;
use Appwrite\Auth\Key;
use Appwrite\Database\Factory as DatabaseFactory;
use Appwrite\Databases\TransactionState;
use Appwrite\Deployment\Backend\Executor as ExecutorBackend;
use Appwrite\Deployment\Backend\Orchestrator;
use Appwrite\Event\Context\Audit as AuditContext;
use Appwrite\Event\Event;
use Appwrite\Event\Message\Func as FunctionMessage;
@@ -21,8 +23,6 @@ use Appwrite\Network\Cors;
use Appwrite\Network\Platform;
use Appwrite\Network\Validator\Origin;
use Appwrite\Network\Validator\Redirect;
use Appwrite\Service\Deployments\Executor as DeploymentsExecutor;
use Appwrite\Service\Deployments\Jobs as DeploymentsJobs;
use Appwrite\Usage\Context as UsageContext;
use Appwrite\Utopia\Database\Documents\User;
use Appwrite\Utopia\Request;
@@ -199,12 +199,14 @@ return function (Container $context): void {
$context->set('deployments', function (BuildPublisher $publisherForBuilds, Jobs $jobs, Database $dbForProject, Document $project, Executor $executor, array $platform, Request $request) {
// The jobs-service orchestrator backend only understands functions
// (its payload builder reads function-shaped attributes like
// `runtime`); sites always build on the executor.
// `runtime`); sites always build on the executor. Transitional:
// once sites build on the jobs-service too, this URI check and the
// nullable Backend params in the VCS trait can both go.
$isSite = \str_starts_with($request->getURI(), '/v1/sites');
return !$isSite && System::getEnv('_APP_BUILDS_BACKEND', 'executor') === 'orchestrator'
? new DeploymentsJobs($jobs, $dbForProject, $project, $platform)
: new DeploymentsExecutor($publisherForBuilds, $dbForProject, $project, $executor, $platform);
? new Orchestrator($jobs, $dbForProject, $project, $platform)
: new ExecutorBackend($publisherForBuilds, $dbForProject, $project, $executor, $platform);
}, ['publisherForBuilds', 'jobs', 'dbForProject', 'project', 'executor', 'platform', 'request']);
$context->set('eventProcessor', fn () => new EventProcessor(), []);
$context->set('databaseFactory', fn (Group $pools, Cache $cache, Authorization $authorization) => new DatabaseFactory(
+2 -2
View File
@@ -1,12 +1,12 @@
<?php
use Appwrite\Database\Factory as DatabaseFactory;
use Appwrite\Deployment\Backend\Orchestrator;
use Appwrite\Event\Event;
use Appwrite\Event\Publisher\Func as FunctionPublisher;
use Appwrite\Event\Publisher\Notification as NotificationPublisher;
use Appwrite\Event\Realtime;
use Appwrite\Event\Webhook;
use Appwrite\Service\Deployments\Jobs as DeploymentsJobs;
use Appwrite\Usage\Context;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Audit\Adapter\Database as AdapterDatabase;
@@ -193,7 +193,7 @@ return function (Container $container): void {
// unlike the HTTP-side 'deployments' resource this doesn't need to pick
// a backend per-request.
$container->set('deployments', function (Jobs $jobs, Database $dbForProject, Document $project, array $platform) {
return new DeploymentsJobs($jobs, $dbForProject, $project, $platform);
return new Orchestrator($jobs, $dbForProject, $project, $platform);
}, ['jobs', 'dbForProject', 'project', 'platform']);
$container->set('logError', function (Registry $register, Document $project) {
@@ -1,6 +1,6 @@
<?php
namespace Appwrite\Service;
namespace Appwrite\Deployment;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -15,7 +15,7 @@ use Utopia\Database\Query;
* fixed for the request's lifetime by which implementation is wired up in
* app/init/resources/request.php.
*/
abstract readonly class Deployments
abstract readonly class Backend
{
public function __construct(
protected Database $dbForProject,
@@ -25,8 +25,8 @@ abstract readonly class Deployments
/**
* Saves chunked-upload progress onto the deployment — source path/size,
* chunk counters, metadata. Never triggers a build; call create() once
* the upload is complete. Pass a single `Document` carrying every field
* chunk counters, metadata. Never triggers a build; call createFromUpload()
* once the upload is complete. Pass a single `Document` carrying every field
* the deployment should end up with: either a fresh, not-yet-persisted
* one (a plain `new Document([...])`), or the existing one fetched from
* the database with more attributes set via `setAttributes()`. A new
@@ -90,7 +90,7 @@ abstract readonly class Deployments
* marked canceled by the caller; this only needs to stop the backend from
* still writing to it.
*/
abstract public function delete(string $deploymentId): void;
abstract public function cancel(string $deploymentId): void;
/**
* Deactivates any other active deployment for $resource before this one
@@ -1,15 +1,15 @@
<?php
namespace Appwrite\Service\Deployments;
namespace Appwrite\Deployment\Backend;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Message\Build as BuildMessage;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Service\Deployments;
use Executor\Executor as ExecutorClient;
use Utopia\Database\Database;
use Utopia\Database\Document;
readonly class Executor extends Deployments
readonly class Executor extends Backend
{
public function __construct(
private BuildPublisher $publisherForBuilds,
@@ -79,7 +79,7 @@ readonly class Executor extends Deployments
return $deployment;
}
public function delete(string $deploymentId): void
public function cancel(string $deploymentId): void
{
$this->executor->deleteRuntime($this->project->getId(), $deploymentId . '-build');
}
@@ -1,12 +1,12 @@
<?php
namespace Appwrite\Service\Deployments;
namespace Appwrite\Deployment\Backend;
use Ahc\Jwt\JWT;
use Appwrite\Deployment\Backend;
use Appwrite\Deployment\Token;
use Appwrite\Service\Deployments;
use OpenRuntimes\Orchestrator\Enum\CallbackEvent;
use OpenRuntimes\Orchestrator\Jobs as JobsClient;
use OpenRuntimes\Orchestrator\Jobs;
use OpenRuntimes\Orchestrator\Model\Artifact\DownloadArtifact;
use OpenRuntimes\Orchestrator\Model\Artifact\StatArtifact;
use OpenRuntimes\Orchestrator\Model\Artifact\UnarchiveArtifact;
@@ -35,10 +35,10 @@ use Utopia\System\System;
* duplicate/rebuild, and templates (public GitHub tarball resolved from a
* git reference).
*/
readonly class Jobs extends Deployments
readonly class Orchestrator extends Backend
{
public function __construct(
private JobsClient $jobs,
private Jobs $jobs,
Database $dbForProject,
Document $project,
private array $platform,
@@ -94,7 +94,7 @@ readonly class Jobs extends Deployments
return $deployment;
}
public function delete(string $deploymentId): void
public function cancel(string $deploymentId): void
{
$this->jobs->delete(static::id($this->project->getId(), $deploymentId));
}
@@ -102,7 +102,7 @@ readonly class Jobs extends Deployments
/**
* @return array<string, mixed> Named arguments for OpenRuntimes\Orchestrator\Jobs::create().
*/
public static function payload(
protected static function payload(
Document $project,
Document $function,
Document $deployment,
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Compute;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Message\Build as BuildMessage;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception;
@@ -9,7 +10,6 @@ use Appwrite\Filter\BranchDomain as BranchDomainFilter;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Validator\Specification as SpecificationValidator;
use Appwrite\Platform\Permission as AppwritePermission;
use Appwrite\Service\Deployments;
use Utopia\Config\Config;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -68,7 +68,7 @@ class Base extends Action
return $allowedSpecifications[0];
}
public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, GitHub $github, bool $activate, array $platform = [], string $referenceType = 'branch', string $reference = '', ?Deployments $deployments = null): Document
public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, GitHub $github, bool $activate, array $platform = [], string $referenceType = 'branch', string $reference = '', ?Backend $deployments = null): Document
{
$deploymentId = ID::unique();
$entrypoint = $function->getAttribute('entrypoint', '');
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Deployments;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Extend\Exception;
use Appwrite\SDK\AuthType;
@@ -9,7 +10,6 @@ use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method;
use Appwrite\SDK\MethodType;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -106,7 +106,7 @@ class Create extends Action
Document $project,
Device $deviceForFunctions,
Device $deviceForLocal,
Deployments $deployments,
Backend $deployments,
array $plan,
Authorization $authorization,
callable $locks
@@ -2,12 +2,12 @@
namespace Appwrite\Platform\Modules\Functions\Http\Deployments\Duplicate;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Extend\Exception;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Helpers\ID;
@@ -73,7 +73,7 @@ class Create extends Action
Response $response,
Database $dbForProject,
Event $queueForEvents,
Deployments $deployments,
Backend $deployments,
Device $deviceForFunctions,
) {
$function = $dbForProject->getDocument('functions', $functionId);
@@ -2,12 +2,12 @@
namespace Appwrite\Platform\Modules\Functions\Http\Deployments\Status;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Extend\Exception;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
@@ -69,7 +69,7 @@ class Update extends Action
Response $response,
Database $dbForProject,
Event $queueForEvents,
Deployments $deployments,
Backend $deployments,
) {
$function = $dbForProject->getDocument('functions', $functionId);
@@ -111,7 +111,7 @@ class Update extends Action
// Best-effort cleanup — the deployment is already marked 'canceled'.
try {
$deployments->delete($deploymentId);
$deployments->cancel($deploymentId);
} catch (\Throwable) {
}
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Deployments\Template;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception;
@@ -10,7 +11,6 @@ use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -100,7 +100,7 @@ class Create extends Base
Event $queueForEvents,
Document $project,
BuildPublisher $publisherForBuilds,
Deployments $deployments,
Backend $deployments,
GitHub $github,
Authorization $authorization,
array $platform
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Deployments\Vcs;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception;
@@ -10,7 +11,6 @@ use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -92,7 +92,7 @@ class Create extends Base
Document $project,
Event $queueForEvents,
BuildPublisher $publisherForBuilds,
Deployments $deployments,
Backend $deployments,
GitHub $github,
array $platform,
) {
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Functions;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Event\Message\Build as BuildMessage;
use Appwrite\Event\Message\Func as FunctionMessage;
@@ -16,7 +17,6 @@ use Appwrite\Platform\Modules\Compute\Validator\Specification;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Task\Validator\Cron;
use Appwrite\Utopia\Database\Validator\CustomId;
use Appwrite\Utopia\Response;
@@ -169,7 +169,7 @@ class Create extends Base
Document $project,
Event $queueForEvents,
BuildPublisher $publisherForBuilds,
Deployments $deployments,
Backend $deployments,
Realtime $queueForRealtime,
Webhook $queueForWebhooks,
FunctionPublisher $publisherForFunctions,
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Functions;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Event\Validator\FunctionEvent;
@@ -11,7 +12,6 @@ use Appwrite\Platform\Modules\Compute\Validator\Specification;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Task\Validator\Cron;
use Appwrite\Utopia\Response;
use Executor\Executor;
@@ -150,7 +150,7 @@ class Update extends Base
Document $project,
Event $queueForEvents,
BuildPublisher $publisherForBuilds,
Deployments $deployments,
Backend $deployments,
Database $dbForPlatform,
GitHub $github,
Executor $executor,
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Functions\Workers;
use Ahc\Jwt\JWT;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Event\Message\Func as FunctionMessage;
use Appwrite\Event\Publisher\Func as FunctionPublisher;
@@ -12,7 +13,6 @@ use Appwrite\Event\Realtime;
use Appwrite\Event\Webhook;
use Appwrite\Extend\Exception as AppwriteException;
use Appwrite\Filter\BranchDomain as BranchDomainFilter;
use Appwrite\Service\Deployments;
use Appwrite\Usage\Build as BuildUsage;
use Appwrite\Usage\Context;
use Appwrite\Utopia\Response\Model\Deployment;
@@ -126,7 +126,7 @@ class Builds extends Action
Device $deviceForFiles,
Log $log,
Executor $executor,
Deployments $deployments,
Backend $deployments,
array $plan
): void {
$payload = $message->getPayload();
@@ -208,7 +208,7 @@ class Builds extends Action
callable $getIsResourceBlocked,
Log $log,
Executor $executor,
Deployments $deployments,
Backend $deployments,
array $plan,
array $platform,
int $timeout
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Functions\Workers;
use Appwrite\Deployment\Backend\Orchestrator;
use Appwrite\Event\Event;
use Appwrite\Event\Message\Func as FunctionMessage;
use Appwrite\Event\Message\Jobs as JobsMessage;
@@ -9,7 +10,6 @@ use Appwrite\Event\Publisher\Func as FunctionPublisher;
use Appwrite\Event\Publisher\Usage as UsagePublisher;
use Appwrite\Event\Realtime;
use Appwrite\Event\Webhook;
use Appwrite\Service\Deployments\Jobs as DeploymentsJobs;
use Appwrite\Usage\Build as BuildUsage;
use Appwrite\Usage\Context as UsageContext;
use Appwrite\Utopia\Response\Model\Deployment;
@@ -209,7 +209,7 @@ class Jobs extends Action
return $this->finalize($dbForProject, $dbForPlatform, $project, $deployment, false, "Build failed with exit code {$exitCode}.", $usage, $publisherForUsage, $github);
}
$path = DeploymentsJobs::buildPath($project->getId(), $deployment->getId());
$path = Orchestrator::buildPath($project->getId(), $deployment->getId());
$size = $deviceForBuilds->exists($path) ? $deviceForBuilds->getFileSize($path) : 0;
$limit = (int) System::getEnv('_APP_COMPUTE_BUILD_SIZE_LIMIT', '2000000000');
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Sites\Http\Deployments;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Event;
use Appwrite\Extend\Exception;
use Appwrite\SDK\AuthType;
@@ -9,7 +10,6 @@ use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method;
use Appwrite\SDK\MethodType;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -107,7 +107,7 @@ class Create extends Action
Event $queueForEvents,
Device $deviceForSites,
Device $deviceForLocal,
Deployments $deployments,
Backend $deployments,
array $plan,
Authorization $authorization,
array $platform,
@@ -339,8 +339,6 @@ class Create extends Action
$fileSize = $deviceForSites->getFileSize($path);
$isNewDeployment = $deployment->isEmpty();
// Start the build
$deployment = $deployments->createFromUpload($site, $deployment->setAttributes([
'$id' => $deploymentId,
'buildCommands' => \implode(' && ', $commands),
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\VCS\Http\GitHub\Authorize\External;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
@@ -9,7 +10,6 @@ use Appwrite\Platform\Modules\VCS\Http\GitHub\Deployment;
use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Response;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -78,7 +78,7 @@ class Update extends Action
Authorization $authorization,
callable $getProjectDB,
BuildPublisher $publisherForBuilds,
Deployments $deployments,
Backend $deployments,
array $platform
) {
$installation = $dbForPlatform->getDocument('installations', $installationId);
@@ -2,11 +2,11 @@
namespace Appwrite\Platform\Modules\VCS\Http\GitHub;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Message\Build as BuildMessage;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception;
use Appwrite\Filter\BranchDomain as BranchDomainFilter;
use Appwrite\Service\Deployments;
use Appwrite\Vcs\Comment;
use Utopia\Config\Config;
use Utopia\Console;
@@ -50,7 +50,7 @@ trait Deployment
BuildPublisher $publisherForBuilds,
callable $getProjectDB,
array $platform,
?Deployments $deployments = null,
?Backend $deployments = null,
) {
$errors = [];
foreach ($repositories as $repository) {
@@ -2,11 +2,11 @@
namespace Appwrite\Platform\Modules\VCS\Http\GitHub\Events;
use Appwrite\Deployment\Backend;
use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\VCS\Http\GitHub\Deployment;
use Appwrite\Service\Deployments;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Utopia\Console;
@@ -57,7 +57,7 @@ class Create extends Action
Authorization $authorization,
callable $getProjectDB,
BuildPublisher $publisherForBuilds,
Deployments $deployments,
Backend $deployments,
array $platform
) {
$this->preprocessEvent($request);
@@ -190,7 +190,7 @@ class Create extends Action
BuildPublisher $publisherForBuilds,
callable $getProjectDB,
array $platform,
?Deployments $deployments = null,
?Backend $deployments = null,
) {
$providerBranchDeleted = $parsedPayload["branchDeleted"] ?? false;
$providerBranch = $parsedPayload["branch"] ?? '';
@@ -237,7 +237,7 @@ class Create extends Action
BuildPublisher $publisherForBuilds,
callable $getProjectDB,
array $platform,
?Deployments $deployments = null,
?Backend $deployments = null,
) {
$action = $parsedPayload["action"] ?? '';