new changes

This commit is contained in:
Niranjan
2026-04-07 20:29:49 +05:30
parent 8fe63c7cf4
commit 31fe556bb0
79 changed files with 2917 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Modules\Jobs;
class CommandOrchestrator
{
private array $acceptedTypes = [
'SITE_CREATE',
'SITE_UPDATE',
'SITE_DELETE',
'DOMAIN_ADD',
'DOMAIN_REMOVE',
'SSL_ISSUE',
'SSL_APPLY',
'SSL_RENEW',
'WEBSERVER_RELOAD',
'FILE_LIST',
'FILE_READ',
'FILE_WRITE',
'CRON_LIST',
'CRON_CREATE',
'CRON_DELETE',
'FIREWALL_RULE_LIST',
'DOCKER_DEPLOY',
'PLUGIN_INSTALL',
'PLUGIN_UPDATE',
'PLUGIN_REMOVE',
'FIREWALL_RULE_ADD',
'FIREWALL_RULE_DELETE',
'BACKUP_RUN',
'BACKUP_RESTORE',
];
public function dispatch(array $commandEnvelope): array
{
$type = (string) ($commandEnvelope['type'] ?? '');
if (!in_array($type, $this->acceptedTypes, true)) {
return [
'job_status' => 'rejected',
'error' => 'Unsupported command type',
];
}
return [
'job_status' => 'queued',
'job_id' => uniqid('job_', true),
'tenant_id' => $commandEnvelope['tenant_id'] ?? null,
'type' => $type,
'idempotency_key' => $commandEnvelope['idempotency_key'] ?? null,
'args' => $commandEnvelope['args'] ?? [],
'message' => 'Command accepted for execution plane dispatch',
];
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Modules\Jobs;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class JobController extends Controller
{
public function __construct(private readonly CommandOrchestrator $orchestrator)
{
}
public function dispatch(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
$payload = $request->all();
$payload['tenant_id'] = $tenantId;
$result = $this->orchestrator->dispatch($payload);
return response()->json(['data' => $result], 202);
}
}