diff --git a/app/src/Application/Payment/Activities/PaymentActivity.php b/app/src/Application/Payment/Activities/PaymentActivity.php deleted file mode 100644 index cabb8ae..0000000 --- a/app/src/Application/Payment/Activities/PaymentActivity.php +++ /dev/null @@ -1,24 +0,0 @@ -logger->getLogger()->debug('Payment status checked', ['paymentId' => $paymentId]); - - return true; - } -} diff --git a/app/src/Application/Payment/Workflows/PaymentWorkflow.php b/app/src/Application/Payment/Workflows/PaymentWorkflow.php deleted file mode 100644 index 40ed38d..0000000 --- a/app/src/Application/Payment/Workflows/PaymentWorkflow.php +++ /dev/null @@ -1,25 +0,0 @@ -withStartToCloseTimeout(10) - ); - - return yield $activity->checkStatus($id); - } -} diff --git a/app/src/Domain/Category/Category.php b/app/src/Domain/Category/Category.php deleted file mode 100644 index bad2701..0000000 --- a/app/src/Domain/Category/Category.php +++ /dev/null @@ -1,9 +0,0 @@ -deleted = Signature::empty(); $this->recordThat( - new ProjectCreated( - $id, - $name, - $description, - $signature + new TransferCreated( + id: $id, + name: $name, + description: $description, + signature: $signature ) ); } @@ -61,7 +61,7 @@ public function aggregateRootId(): AggregateRootId return $this->id; } - public function id(): ProjectId + public function id(): TransferId { return $this->id; } diff --git a/app/src/Domain/Project/ProjectId.php b/app/src/Domain/Transfer/TransferId.php similarity index 53% rename from app/src/Domain/Project/ProjectId.php rename to app/src/Domain/Transfer/TransferId.php index f923548..4fb0f1c 100644 --- a/app/src/Domain/Project/ProjectId.php +++ b/app/src/Domain/Transfer/TransferId.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Domain\Project; +namespace Domain\Transfer; use Domain\Shared\Typecasts\Id; -final class ProjectId extends Id +final class TransferId extends Id { } diff --git a/app/src/Domain/Transfer/Contracts/TransferWebsiteWorkflowInterface.php b/app/src/Domain/Transfer/Workflows/TransferWebsiteWorkflowInterface.php similarity index 90% rename from app/src/Domain/Transfer/Contracts/TransferWebsiteWorkflowInterface.php rename to app/src/Domain/Transfer/Workflows/TransferWebsiteWorkflowInterface.php index 0dc0f93..cc9a9dd 100644 --- a/app/src/Domain/Transfer/Contracts/TransferWebsiteWorkflowInterface.php +++ b/app/src/Domain/Transfer/Workflows/TransferWebsiteWorkflowInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Domain\Transfer\Contracts; +namespace Domain\Transfer\Workflows; use Application\Transfer\DTO\TransferDetails; use Temporal\Workflow\WorkflowInterface; diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AllocateSpace.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AllocateSpace.php new file mode 100644 index 0000000..f39f3a0 --- /dev/null +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AllocateSpace.php @@ -0,0 +1,29 @@ +boolean(40)) { + throw new AllocateSpaceFailedException(); + } + + // Simulate long-running Amazon Block Storage allocation + sleep(5); + + return Uuid::uuid7()->toString(); + } +} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AllocateSpaceActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AllocateSpaceActivity.php deleted file mode 100644 index eb2740d..0000000 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AllocateSpaceActivity.php +++ /dev/null @@ -1,22 +0,0 @@ -toString(); - } -} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AttachDomain.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AttachDomain.php new file mode 100644 index 0000000..8e0029e --- /dev/null +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AttachDomain.php @@ -0,0 +1,29 @@ +boolean(40)) { + throw new AttachDomainFailedException(); + } + + // Attach domain in destination + sleep(5); + + return Uuid::uuid7()->toString(); + } +} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AttachDomainActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AttachDomainActivity.php deleted file mode 100644 index 745939c..0000000 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/AttachDomainActivity.php +++ /dev/null @@ -1,22 +0,0 @@ -toString(); - } -} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/DestinationStub.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/DestinationStub.php index 7c3b83f..ade1be8 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/DestinationStub.php +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/DestinationStub.php @@ -12,62 +12,62 @@ final class DestinationStub { - public static function restoreDatabase(): ActivityProxy|RestoreDatabaseActivity + public static function restoreDatabase(): ActivityProxy|RestoreDatabase { return Workflow::newActivityStub( - RestoreDatabaseActivity::class, + RestoreDatabase::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } - public static function restoreFiles(): ActivityProxy|RestoreFilesActivity + public static function restoreFiles(): ActivityProxy|RestoreFiles { return Workflow::newActivityStub( - RestoreFilesActivity::class, + RestoreFiles::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } - public static function allocateSpace(): ActivityProxy|AllocateSpaceActivity + public static function allocateSpace(): ActivityProxy|AllocateSpace { return Workflow::newActivityStub( - AllocateSpaceActivity::class, + AllocateSpace::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } - public static function attachDomain(): ActivityProxy|AttachDomainActivity + public static function attachDomain(): ActivityProxy|AttachDomain { return Workflow::newActivityStub( - AttachDomainActivity::class, + AttachDomain::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } - public static function reConfigureWebsite(): ActivityProxy|ReConfigureWebsiteActivity + public static function reConfigureWebsite(): ActivityProxy|ReConfigureWebsite { return Workflow::newActivityStub( - ReConfigureWebsiteActivity::class, + ReConfigureWebsite::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/ReConfigureWebsiteActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/ReConfigureWebsite.php similarity index 66% rename from app/src/Infrastructure/Temporal/Transfer/Activities/Destination/ReConfigureWebsiteActivity.php rename to app/src/Infrastructure/Temporal/Transfer/Activities/Destination/ReConfigureWebsite.php index db9c811..1ef4899 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/ReConfigureWebsiteActivity.php +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/ReConfigureWebsite.php @@ -4,13 +4,12 @@ namespace Infrastructure\Temporal\Transfer\Activities\Destination; +use Domain\Transfer\Activities\Destination\ReConfigureWebsiteInterface; use Ramsey\Uuid\Uuid; -use Temporal\Activity\ActivityInterface; use function sleep; -#[ActivityInterface(prefix: 'website.transfer.destination.')] -final readonly class ReConfigureWebsiteActivity +final readonly class ReConfigureWebsite implements ReConfigureWebsiteInterface { public function handle(): string { diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreDatabaseActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreDatabase.php similarity index 67% rename from app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreDatabaseActivity.php rename to app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreDatabase.php index 1f3c7e1..630209b 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreDatabaseActivity.php +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreDatabase.php @@ -4,13 +4,12 @@ namespace Infrastructure\Temporal\Transfer\Activities\Destination; +use Domain\Transfer\Activities\Destination\RestoreDatabaseInterface; use Ramsey\Uuid\Uuid; -use Temporal\Activity\ActivityInterface; use function sleep; -#[ActivityInterface(prefix: 'website.transfer.destination.')] -final readonly class RestoreDatabaseActivity +final readonly class RestoreDatabase implements RestoreDatabaseInterface { public function handle(): string { diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreFilesActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreFiles.php similarity index 68% rename from app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreFilesActivity.php rename to app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreFiles.php index aecfe37..6625005 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreFilesActivity.php +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Destination/RestoreFiles.php @@ -4,13 +4,12 @@ namespace Infrastructure\Temporal\Transfer\Activities\Destination; +use Domain\Transfer\Activities\Destination\RestoreFilesInterface; use Ramsey\Uuid\Uuid; -use Temporal\Activity\ActivityInterface; use function sleep; -#[ActivityInterface(prefix: 'website.transfer.destination.')] -final readonly class RestoreFilesActivity +final readonly class RestoreFiles implements RestoreFilesInterface { public function handle(): string { diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/BackupDatabase.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/BackupDatabase.php new file mode 100644 index 0000000..a90b45b --- /dev/null +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/BackupDatabase.php @@ -0,0 +1,29 @@ +boolean(40)) { + throw new AllocateSpaceFailedException(); + } + + // Initiate database backup on source website + sleep(5); + + return Uuid::uuid7()->toString(); + } +} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/BackupFiles.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/BackupFiles.php new file mode 100644 index 0000000..abf4c17 --- /dev/null +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/BackupFiles.php @@ -0,0 +1,29 @@ +boolean(60)) { + throw new BackupFilesFailedException(); + } + + // Initiates the backup of files from the source website. + sleep(5); + + return Uuid::uuid7()->toString(); + } +} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/InitiateDatabaseBackupActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/InitiateDatabaseBackupActivity.php deleted file mode 100644 index 4d0c5b6..0000000 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/InitiateDatabaseBackupActivity.php +++ /dev/null @@ -1,22 +0,0 @@ -toString(); - } -} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/InitiateFilesBackupActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/InitiateFilesBackupActivity.php deleted file mode 100644 index 2c4684b..0000000 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/InitiateFilesBackupActivity.php +++ /dev/null @@ -1,22 +0,0 @@ -toString(); - } -} diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/ReleaseDomainActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/ReleaseDomain.php similarity index 65% rename from app/src/Infrastructure/Temporal/Transfer/Activities/Source/ReleaseDomainActivity.php rename to app/src/Infrastructure/Temporal/Transfer/Activities/Source/ReleaseDomain.php index c2bb7e8..bc74b90 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/ReleaseDomainActivity.php +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/ReleaseDomain.php @@ -4,13 +4,12 @@ namespace Infrastructure\Temporal\Transfer\Activities\Source; +use Domain\Transfer\Activities\Source\ReleaseDomainInterface; use Ramsey\Uuid\Uuid; -use Temporal\Activity\ActivityInterface; use function sleep; -#[ActivityInterface(prefix: 'website.transfer.source.releaseDomain.')] -final readonly class ReleaseDomainActivity +final readonly class ReleaseDomain implements ReleaseDomainInterface { public function handle(): string { diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/SourceStub.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/SourceStub.php index 9da80c0..2e6f248 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/SourceStub.php +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/SourceStub.php @@ -12,50 +12,50 @@ final class SourceStub { - public static function initiateFilesBackup(): ActivityProxy|InitiateFilesBackupActivity + public static function backupFiles(): ActivityProxy|BackupFiles { return Workflow::newActivityStub( - InitiateFilesBackupActivity::class, + BackupFiles::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } - public static function initiateDatabaseBackup(): ActivityProxy|InitiateDatabaseBackupActivity + public static function backupDatabase(): ActivityProxy|BackupDatabase { return Workflow::newActivityStub( - InitiateDatabaseBackupActivity::class, + BackupDatabase::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } - public static function releaseDomain(): ActivityProxy|ReleaseDomainActivity + public static function releaseDomain(): ActivityProxy|ReleaseDomain { return Workflow::newActivityStub( - ReleaseDomainActivity::class, + ReleaseDomain::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } - public static function transferBackup(): ActivityProxy|TransferBackupActivity + public static function transferBackup(): ActivityProxy|TransferBackup { return Workflow::newActivityStub( - TransferBackupActivity::class, + TransferBackup::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minute()) ->withRetryOptions( - RetryOptions::new()->withMaximumAttempts(1), + RetryOptions::new()->withMaximumAttempts(7), ), ); } diff --git a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/TransferBackupActivity.php b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/TransferBackup.php similarity index 72% rename from app/src/Infrastructure/Temporal/Transfer/Activities/Source/TransferBackupActivity.php rename to app/src/Infrastructure/Temporal/Transfer/Activities/Source/TransferBackup.php index 91893fb..eace4d6 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Activities/Source/TransferBackupActivity.php +++ b/app/src/Infrastructure/Temporal/Transfer/Activities/Source/TransferBackup.php @@ -4,13 +4,12 @@ namespace Infrastructure\Temporal\Transfer\Activities\Source; +use Domain\Transfer\Activities\Source\TransferBackupInterface; use Ramsey\Uuid\Uuid; -use Temporal\Activity\ActivityInterface; use function sleep; -#[ActivityInterface(prefix: 'website.transfer.source.')] -final readonly class TransferBackupActivity +final readonly class TransferBackup implements TransferBackupInterface { public function handle(): string { diff --git a/app/src/Infrastructure/Temporal/Transfer/Workflows/TransferWebsiteWorkflow.php b/app/src/Infrastructure/Temporal/Transfer/Workflows/TransferWebsiteWorkflow.php index 9254c8f..2845f2f 100644 --- a/app/src/Infrastructure/Temporal/Transfer/Workflows/TransferWebsiteWorkflow.php +++ b/app/src/Infrastructure/Temporal/Transfer/Workflows/TransferWebsiteWorkflow.php @@ -5,7 +5,8 @@ namespace Infrastructure\Temporal\Transfer\Workflows; use Application\Transfer\DTO\TransferDetails; -use Domain\Transfer\Contracts\TransferWebsiteWorkflowInterface; +use Domain\Transfer\Workflows\TransferWebsiteWorkflowInterface; +use Generator; use Infrastructure\Temporal\Transfer\Activities\Destination\DestinationStub; use Infrastructure\Temporal\Transfer\Activities\Source\SourceStub; use Throwable; @@ -16,9 +17,9 @@ final class TransferWebsiteWorkflow implements TransferWebsiteWorkflowInterface public function __construct() { - $this->actions[] = SourceStub::initiateFilesBackup(); + $this->actions[] = SourceStub::backupFiles(); $this->actions[] = SourceStub::releaseDomain(); - $this->actions[] = SourceStub::initiateDatabaseBackup(); + $this->actions[] = SourceStub::backupDatabase(); $this->actions[] = SourceStub::transferBackup(); $this->actions[] = DestinationStub::allocateSpace(); $this->actions[] = DestinationStub::restoreDatabase(); @@ -26,7 +27,10 @@ public function __construct() $this->actions[] = DestinationStub::attachDomain(); } - public function handle(TransferDetails $transferDetails) + /** + * @throws Throwable + */ + public function handle(TransferDetails $transferDetails): Generator { foreach ($this->actions as $action) { try { @@ -34,6 +38,9 @@ public function handle(TransferDetails $transferDetails) } catch (Throwable $e) { // Handle or log the error // todo: Log error + // throw $e; + + return; } } }