Skip to content

Commit 26cb526

Browse files
committed
feat: workflow example
1 parent fc94dae commit 26cb526

26 files changed

+644
-13
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
uses: shivammathur/setup-php@2.31.1
9696
with:
9797
php-version: ${{ matrix.php-version }}
98-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal
98+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal, grpc
9999
ini-values: error_reporting=E_ALL
100100
coverage: none
101101
tools: phive

.github/workflows/dependency-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
uses: shivammathur/setup-php@2.31.1
4747
with:
4848
php-version: ${{ matrix.php-version }}
49-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal
49+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal, grpc
5050
ini-values: error_reporting=E_ALL
5151
coverage: none
5252
tools: phive
@@ -109,7 +109,7 @@ jobs:
109109
uses: shivammathur/setup-php@2.31.1
110110
with:
111111
php-version: ${{ matrix.php-version }}
112-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal
112+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal, grpc
113113
ini-values: error_reporting=E_ALL
114114
coverage: none
115115
tools: phive

.github/workflows/refactoring.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
uses: shivammathur/setup-php@2.31.1
4242
with:
4343
php-version: ${{ matrix.php-version }}
44-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal
44+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, sockets, decimal, grpc
4545
ini-values: error_reporting=E_ALL
4646
coverage: none
4747

.github/workflows/security-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: shivammathur/setup-php@2.31.1
3737
with:
3838
php-version: ${{ matrix.php-version }}
39-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, sockets, decimal
39+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, sockets, decimal, grpc
4040
ini-values: error_reporting=E_ALL
4141
coverage: none
4242

.github/workflows/static-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: shivammathur/setup-php@2.31.1
3636
with:
3737
php-version: ${{ matrix.php-version }}
38-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, opcache, pcntl, posix, sockets, decimal
38+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, opcache, pcntl, posix, sockets, decimal, grpc
3939
ini-values: error_reporting=E_ALL
4040
coverage: none
4141

@@ -89,7 +89,7 @@ jobs:
8989
uses: shivammathur/setup-php@2.31.1
9090
with:
9191
php-version: ${{ matrix.php-version }}
92-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, pdo_mysql, curl, fileinfo, opcache, pcntl, posix, sockets, decimal
92+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, pdo_mysql, curl, fileinfo, opcache, pcntl, posix, sockets, decimal, grpc
9393
ini-values: error_reporting=E_ALL
9494
coverage: xdebug
9595

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
uses: shivammathur/setup-php@2.31.1
4343
with:
4444
php-version: ${{ matrix.php-version }}
45-
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, pdo_mysql, pdo_sqlite, curl, fileinfo, opcache, pcntl, posix, sockets, decimal
45+
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, pdo_mysql, pdo_sqlite, curl, fileinfo, opcache, pcntl, posix, sockets, decimal, grpc
4646
ini-values: error_reporting=E_ALL
4747
coverage: xdebug
4848

app/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"ext-mbstring": "*",
4040
"ext-pdo": "*",
4141
"ext-sockets": "*",
42+
"ext-grpc": "*",
4243
"beberlei/assert": "^3.3",
4344
"cycle/annotated": "^4.2",
4445
"cycle/database": "^2.11",
@@ -52,6 +53,7 @@
5253
"spiral-packages/laravel-validator": "^1.1",
5354
"spiral-packages/league-event": "^1.0",
5455
"spiral-packages/scheduler": "^2.3",
56+
"spiral-packages/swagger-php": "^1.0",
5557
"spiral-packages/yii-error-handler-bridge": "^1.1",
5658
"spiral/cycle-bridge": "^2.10",
5759
"spiral/data-grid-bridge": "^3.0",

app/composer.lock

Lines changed: 145 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Application\Transfer\DTO;
6+
7+
use OpenApi\Attributes as OAT;
8+
9+
class TransferDetails
10+
{
11+
#[OAT\Property(format: 'string', example: '10ab5df0-693a-4cd8-8ed5-1e702947d4d0')]
12+
public string $transferId;
13+
14+
#[OAT\Property(format: 'string', example: '10ab5df0-693a-4cd8-8ed5-1e702947d4d0')]
15+
public string $fromUserId;
16+
17+
#[OAT\Property(format: 'string', example: '10ab5df0-693a-4cd8-8ed5-1e702947d4d0')]
18+
public string $toUserId;
19+
20+
#[OAT\Property(format: 'string', example: 'https://wayof.dev')]
21+
public string $fromDomain;
22+
23+
#[OAT\Property(format: 'string', example: 'https://your-dev.way')]
24+
public string $toDomain;
25+
26+
public function __construct(
27+
string $transferId,
28+
string $fromUserId,
29+
string $toUserId,
30+
string $fromDomain,
31+
string $toDomain,
32+
) {
33+
$this->transferId = $transferId;
34+
$this->fromUserId = $fromUserId;
35+
$this->toUserId = $toUserId;
36+
$this->fromDomain = $fromDomain;
37+
$this->toDomain = $toDomain;
38+
}
39+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Bridge\Spiral\Console;
6+
7+
use Application\Transfer\DTO\TransferDetails;
8+
use Infrastructure\Temporal\Transfer\Workflows\TransferWebsiteWorkflowStub;
9+
use Spiral\Console\Attribute\AsCommand;
10+
use Spiral\Console\Command;
11+
use Temporal\Client\WorkflowClientInterface;
12+
13+
/**
14+
* @psalm-suppress PropertyNotSetInConstructor
15+
*/
16+
#[AsCommand(name: 'website:transfer', description: 'Transfer website from source to destination')]
17+
class TransferCommand extends Command
18+
{
19+
public function __invoke(WorkflowClientInterface $workflow): int
20+
{
21+
$transferDetails = new TransferDetails(
22+
transferId: '10ab5df0-693a-4cd8-8ed5-1e702947d4d0',
23+
fromUserId: '10ab5df0-693a-4cd8-8ed5-1e702947d4d0',
24+
toUserId: '10ab5df0-693a-4cd8-8ed5-1e702947d4d0',
25+
fromDomain: 'https://wayof.dev',
26+
toDomain: 'https://your-dev.way'
27+
);
28+
29+
TransferWebsiteWorkflowStub::handle($workflow, $transferDetails);
30+
31+
return self::SUCCESS;
32+
}
33+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Domain\Transfer\Contracts;
6+
7+
use Application\Transfer\DTO\TransferDetails;
8+
use Temporal\Workflow\WorkflowInterface;
9+
use Temporal\Workflow\WorkflowMethod;
10+
11+
#[WorkflowInterface]
12+
interface TransferWebsiteWorkflowInterface
13+
{
14+
#[WorkflowMethod(name: 'website.transfer')]
15+
public function handle(TransferDetails $transferDetails);
16+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Infrastructure\Temporal\Transfer\Activities\Destination;
6+
7+
use Ramsey\Uuid\Uuid;
8+
use Temporal\Activity\ActivityInterface;
9+
10+
use function sleep;
11+
12+
#[ActivityInterface(prefix: 'website.transfer.destination.')]
13+
final readonly class AllocateSpaceActivity
14+
{
15+
public function handle(): string
16+
{
17+
// Simulate long-running Amazon Block Storage allocation
18+
sleep(5);
19+
20+
return Uuid::uuid7()->toString();
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Infrastructure\Temporal\Transfer\Activities\Destination;
6+
7+
use Ramsey\Uuid\Uuid;
8+
use Temporal\Activity\ActivityInterface;
9+
10+
use function sleep;
11+
12+
#[ActivityInterface(prefix: 'website.transfer.destination.')]
13+
final readonly class AttachDomainActivity
14+
{
15+
public function handle(): string
16+
{
17+
// Attach domain in destination
18+
sleep(5);
19+
20+
return Uuid::uuid7()->toString();
21+
}
22+
}

0 commit comments

Comments
 (0)