Skip to content

Commit 2008715

Browse files
committed
fix runtimes: http-api + hook
1 parent e65c423 commit 2008715

File tree

20 files changed

+1078
-323
lines changed

20 files changed

+1078
-323
lines changed

bin/satellite

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ use Symfony\Component\Console\Output;
1919
$app = new \Symfony\Component\Console\Application();
2020

2121
$app->addCommands([
22+
new \Kiboko\Component\Satellite\Console\Command\ApiRunCommand(),
2223
new \Kiboko\Component\Satellite\Console\Command\BuildCommand(),
24+
new \Kiboko\Component\Satellite\Console\Command\HookRunCommand(),
2325
new \Kiboko\Component\Satellite\Console\Command\ValidateCommand(),
2426
new \Kiboko\Component\Satellite\Console\Command\PipelineRunCommand(),
2527
new \Kiboko\Component\Satellite\Console\Command\WorkflowRunCommand(),

project-fpm/caddy/Caddyfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
localhost:4000 {
22
reverse_proxy /foo/* satellite-1:9000 {
33
transport fastcgi {
4-
root /var/www/html/index.php
4+
root /var/www/html/main.php
55
}
66
}
77
reverse_proxy /bar/* satellite-2:9000 {
88
transport fastcgi {
9-
root /var/www/html/index.php
9+
root /var/www/html/main.php
1010
}
1111
}
1212

project-fpm/docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ services:
44
http:
55
image: caddy:2-alpine
66
volumes:
7-
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
8-
- ./index.html:/var/www/html/index.html
9-
- caddy_data:/data
7+
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
8+
- ./index.html:/var/www/html/index.html
9+
- caddy_data:/data
1010
ports:
11-
- '4000:4000'
11+
- '4000:4000'
1212

1313
satellite-1:
14-
image: kiboko/satellite-1
14+
image: kiboko/satellite:foo
1515

1616
satellite-2:
17-
image: kiboko/satellite-1
17+
image: kiboko/satellite:bar
1818

1919
volumes:
2020
caddy_data:

project-fpm/hello.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

project-fpm/http-api.yaml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
satellite:
2-
docker:
3-
from: php:8.0-fpm-alpine
4-
workdir: /var/www/html
5-
tags:
6-
- kiboko/satellite:foo
7-
- kiboko/satellite:bar
8-
# filesystem:
9-
# path: foo
2+
# docker:
3+
# from: php:8.0-fpm-alpine
4+
# workdir: /var/www/html
5+
# tags:
6+
# - kiboko/satellite:foo
7+
# - kiboko/satellite:bar
8+
filesystem:
9+
path: foo
1010
composer:
1111
# from_local: true
12-
autoload:
13-
psr4:
14-
- namespace: "Pipeline\\"
15-
paths: [ "" ]
1612
require:
17-
- "psr/http-message:^1.0@dev"
18-
- "psr/http-factory:^1.0@dev"
19-
- "psr/http-server-handler:^1.0@dev"
2013
- "middlewares/uuid:dev-master"
2114
- "middlewares/base-path:dev-master"
2215
- "middlewares/request-handler:dev-master"
2316
- "middlewares/fast-route:dev-master"
2417
- "laminas/laminas-diactoros"
25-
- "laminas/laminas-httphandlerrunner:1.2.x-dev"
18+
- "laminas/laminas-httphandlerrunner"
19+
- "nyholm/psr7-server"
20+
- "nyholm/psr7"
21+
- "php-etl/pipeline"
22+
- "php-etl/satellite"
23+
- "php-etl/api-runtime"
24+
- "php-etl/mapping-contracts"
25+
- "tuupola/slim-jwt-auth"
26+
- "tuupola/slim-basic-auth"
2627
http_api:
2728
path: /foo
29+
authorization:
30+
jwt:
31+
secret: 'my_secret'
2832
routes:
2933
- route: /hello
34+
expression: 'input["_items"]'
3035
pipeline:
3136
steps:
3237
- fastmap:
3338
map:
3439
- field: '[sku]'
3540
copy: '[sku]'
36-
- field: '[title]'
37-
expression: 'input["sku"] ~" | "~ input["name"]'
3841
- field: '[name]'
3942
copy: '[name]'
4043
- field: '[staticValue]'
@@ -48,14 +51,13 @@ satellite:
4851
logger:
4952
type: stderr
5053
- route: /events/products
54+
expression: 'input["_items"]'
5155
pipeline:
5256
steps:
5357
- fastmap:
5458
map:
5559
- field: '[sku]'
5660
copy: '[sku]'
57-
- field: '[title]'
58-
expression: 'input["sku"] ~" | "~ input["name"]'
5961
- field: '[name]'
6062
copy: '[name]'
6163
- field: '[staticValue]'

project-fpm/http-hook.yaml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
satellite:
2-
docker:
3-
from: php:8.0-fpm-alpine
4-
workdir: /var/www/html
5-
tags:
6-
- kiboko/satellite:foo
7-
- kiboko/satellite:bar
8-
# filesystem:
9-
# path: foo
2+
# docker:
3+
# from: php:8.0-fpm-alpine
4+
# workdir: /var/www/html
5+
# tags:
6+
# - kiboko/satellite:foo
7+
# - kiboko/satellite:bar
8+
filesystem:
9+
path: foo
1010
composer:
1111
# from_local: true
12-
autoload:
13-
psr4:
14-
- namespace: "Pipeline\\"
15-
paths: [ "" ]
1612
require:
17-
- "psr/http-message:^1.0@dev"
18-
- "psr/http-factory:^1.0@dev"
19-
- "psr/http-server-handler:^1.0@dev"
2013
- "middlewares/uuid:dev-master"
2114
- "middlewares/base-path:dev-master"
2215
- "middlewares/request-handler:dev-master"
23-
- "middlewares/fast-route:dev-master"
2416
- "laminas/laminas-diactoros"
25-
- "laminas/laminas-httphandlerrunner:1.2.x-dev"
17+
- "laminas/laminas-httphandlerrunner"
18+
- "nyholm/psr7-server"
19+
- "nyholm/psr7"
20+
- "php-etl/hook-runtime"
21+
- "symfony/expression-language"
22+
- "php-etl/mapping-contracts"
23+
- "tuupola/slim-jwt-auth"
24+
- "tuupola/slim-basic-auth"
2625
http_hook:
2726
path: /bar/hello
27+
authorization:
28+
basic:
29+
- user: john
30+
password: my_password
31+
- user: bill
32+
password: other_password
33+
expression: 'input["_items"]'
2834
pipeline:
2935
steps:
3036
- fastmap:
@@ -36,7 +42,7 @@ satellite:
3642
- field: '[name]'
3743
copy: '[name]'
3844
- field: '[staticValue]'
39-
constant: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis efficitur justo, id facilisis elit venenatis et. Sed fermentum posuere convallis. Phasellus lectus neque, bibendum sit amet enim imperdiet, dignissim blandit nisi. Donec nec neque nisi. Vivamus luctus facilisis nibh id rhoncus. Vestibulum eget facilisis tortor. Etiam at cursus enim, vitae mollis ex. Proin at velit at erat bibendum ultricies. Duis ut velit malesuada, placerat nisl a, ultrices tortor.'
45+
constant: 'Lorem ipsum dolor sit amet'
4046
- csv:
4147
loader:
4248
file_path: output.csv

src/Builder/API.php

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,53 @@ final class API implements Builder
1111
{
1212
public function getNode(): Node
1313
{
14-
return new Node\Expr\Closure(subNodes: [
15-
'params' => [
16-
new Node\Param(
17-
var: new Node\Expr\Variable('request')
14+
return new Node\Stmt\Return_(
15+
new Node\Expr\MethodCall(
16+
new Node\Expr\MethodCall(
17+
new Node\Expr\Variable('psr17Factory'),
18+
'createResponse',
19+
[
20+
new Node\Arg(
21+
new Node\Scalar\LNumber(200),
22+
),
23+
]
1824
),
19-
],
20-
]);
25+
'withBody',
26+
[
27+
new Node\Arg(
28+
new Node\Expr\MethodCall(
29+
new Node\Expr\Variable('psr17Factory'),
30+
'createStream',
31+
[
32+
new Node\Arg(
33+
new Node\Expr\FuncCall(
34+
new Node\Name('json_encode'),
35+
[
36+
new Node\Arg(
37+
new Node\Expr\Array_(
38+
[
39+
new Node\Expr\ArrayItem(
40+
new Node\Expr\Variable('response'),
41+
new Node\Scalar\String_('message')
42+
),
43+
new Node\Expr\ArrayItem(
44+
new Node\Expr\FuncCall(new Node\Name('gethostname')),
45+
new Node\Scalar\String_('server')
46+
),
47+
],
48+
[
49+
'kind' => Node\Expr\Array_::KIND_SHORT,
50+
]
51+
)
52+
),
53+
]
54+
)
55+
),
56+
]
57+
)
58+
),
59+
]
60+
)
61+
);
2162
}
2263
}

src/Builder/API/APIRuntime.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Satellite\Builder\API;
6+
7+
use PhpParser\Node;
8+
9+
final class APIRuntime
10+
{
11+
public function getNode(): Node\Expr
12+
{
13+
return new Node\Expr\New_(
14+
class: new Node\Name\FullyQualified('Kiboko\\Component\\Runtime\\API\\APIRuntime'),
15+
args: [
16+
new Node\Arg(
17+
value: new Node\Expr\New_(
18+
class: new Node\Name\FullyQualified(\Kiboko\Component\Pipeline\Pipeline::class),
19+
args: [
20+
new Node\Arg(
21+
value: new Node\Expr\New_(
22+
class: new Node\Name\FullyQualified(\Kiboko\Component\Pipeline\PipelineRunner::class),
23+
args: [
24+
new Node\Arg(
25+
value: new Node\Expr\New_(
26+
class: new Node\Name\FullyQualified(\Psr\Log\NullLogger::class)
27+
)
28+
),
29+
]
30+
)
31+
),
32+
]
33+
),
34+
),
35+
new Node\Arg(
36+
value: new Node\Expr\New_(
37+
class: new Node\Name\FullyQualified('ProjectServiceContainer')
38+
),
39+
),
40+
]
41+
);
42+
}
43+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Kiboko\Component\Satellite\Builder\API;
6+
7+
use PhpParser\Builder;
8+
use PhpParser\Node;
9+
10+
final readonly class PipelineBuilder
11+
{
12+
public function __construct(private Builder $builder)
13+
{
14+
}
15+
16+
public function getNode(): Node\Expr
17+
{
18+
return new Node\Expr\Closure(
19+
subNodes: [
20+
'static' => true,
21+
'params' => [
22+
new Node\Param(
23+
var: new Node\Expr\Variable('runtime'),
24+
type: new Node\Name\FullyQualified('Kiboko\\Component\\Runtime\\Hook\\HookRuntimeInterface'),
25+
),
26+
],
27+
'stmts' => [
28+
new Node\Stmt\Expression(
29+
$this->builder->getNode()
30+
),
31+
new Node\Stmt\Return_(
32+
expr: new Node\Expr\Variable('runtime')
33+
),
34+
],
35+
]
36+
);
37+
}
38+
}

0 commit comments

Comments
 (0)