Skip to content

Commit

Permalink
Removed runtime packages (see github.com/php-etl/runtime-distribution)
Browse files Browse the repository at this point in the history
  • Loading branch information
gplanchat committed Nov 20, 2023
1 parent 247b399 commit e7d4f07
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/Builder/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function __construct(
) {}

public function addExtractor(
Node\Expr|Builder $code,
Node\Expr|Builder $extractor,
Node\Expr|Builder $rejection,
Node\Expr|Builder $state,
Expand All @@ -24,6 +25,7 @@ public function addExtractor(
var: $runtime,
name: new Node\Identifier('extract'),
args: [
new Node\Arg($code instanceof Builder ? $code->getNode() : $code),
new Node\Arg($extractor instanceof Builder ? $extractor->getNode() : $extractor),
new Node\Arg($rejection instanceof Builder ? $rejection->getNode() : $rejection),
new Node\Arg($state instanceof Builder ? $state->getNode() : $state),
Expand All @@ -34,6 +36,7 @@ public function addExtractor(
}

public function addTransformer(
Node\Expr|Builder $code,
Node\Expr|Builder $transformer,
Node\Expr|Builder $rejection,
Node\Expr|Builder $state,
Expand All @@ -42,6 +45,7 @@ public function addTransformer(
var: $runtime,
name: new Node\Identifier('transform'),
args: [
new Node\Arg($code instanceof Builder ? $code->getNode() : $code),
new Node\Arg($transformer instanceof Builder ? $transformer->getNode() : $transformer),
new Node\Arg($rejection instanceof Builder ? $rejection->getNode() : $rejection),
new Node\Arg($state instanceof Builder ? $state->getNode() : $state),
Expand All @@ -52,6 +56,7 @@ public function addTransformer(
}

public function addLoader(
Node\Expr|Builder $code,
Node\Expr|Builder $loader,
Node\Expr|Builder $rejection,
Node\Expr|Builder $state,
Expand All @@ -60,6 +65,7 @@ public function addLoader(
var: $runtime,
name: new Node\Identifier('load'),
args: [
new Node\Arg($code instanceof Builder ? $code->getNode() : $code),
new Node\Arg($loader instanceof Builder ? $loader->getNode() : $loader),
new Node\Arg($rejection instanceof Builder ? $rejection->getNode() : $rejection),
new Node\Arg($state instanceof Builder ? $state->getNode() : $state),
Expand Down
14 changes: 13 additions & 1 deletion src/Pipeline/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

final readonly class Extractor implements StepInterface
{
public function __construct(private ?string $plugin, private ?string $key, private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage()) {}
public function __construct(
private ?string $plugin,
private ?string $key,
private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage()
) {
}

public function __invoke(array $config, Pipeline $pipeline, StepRepositoryInterface $repository): void
{
Expand Down Expand Up @@ -61,7 +66,14 @@ public function __invoke(array $config, Pipeline $pipeline, StepRepositoryInterf
);
}

if (array_key_exists('code', $config)) {
$code = new Node\Scalar\String_($config['code']);
} else {
$code = new node\Scalar\String_(sprintf('%s.%s', $this->plugin, $this->key));
}

$pipeline->addExtractor(
$code,
$repository->getBuilder()
->withLogger($logger)
->withRejection($rejection)
Expand Down
14 changes: 13 additions & 1 deletion src/Pipeline/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

final readonly class Loader implements StepInterface
{
public function __construct(private ?string $plugin, private ?string $key, private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage()) {}
public function __construct(
private ?string $plugin,
private ?string $key,
private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage()
) {
}

public function __invoke(array $config, Pipeline $pipeline, StepRepositoryInterface $repository): void
{
Expand Down Expand Up @@ -61,7 +66,14 @@ public function __invoke(array $config, Pipeline $pipeline, StepRepositoryInterf
);
}

if (array_key_exists('code', $config)) {
$code = new Node\Scalar\String_($config['code']);
} else {
$code = new node\Scalar\String_(sprintf('%s.%s', $this->plugin, $this->key));
}

$pipeline->addLoader(
$code,
$repository->getBuilder()
->withLogger($logger)
->withRejection($rejection)
Expand Down
14 changes: 13 additions & 1 deletion src/Pipeline/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

final readonly class Transformer implements StepInterface
{
public function __construct(private ?string $plugin, private ?string $key, private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage()) {}
public function __construct(
private ?string $plugin,
private ?string $key,
private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage()
) {
}

public function __invoke(array $config, Pipeline $pipeline, StepRepositoryInterface $repository): void
{
Expand Down Expand Up @@ -61,7 +66,14 @@ public function __invoke(array $config, Pipeline $pipeline, StepRepositoryInterf
);
}

if (array_key_exists('code', $config)) {
$code = new Node\Scalar\String_($config['code']);
} else {
$code = new node\Scalar\String_(sprintf('%s.%s', $this->plugin, $this->key));
}

$pipeline->addTransformer(
$code,
$repository->getBuilder()
->withLogger($logger)
->withRejection($rejection)
Expand Down
5 changes: 4 additions & 1 deletion src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ private function compileWorkflow(array $config): Satellite\Builder\Repository\Wo
$repository = new Satellite\Builder\Repository\Workflow($workflow);

$repository->addPackages(
'php-etl/satellite-contracts:>=0.1.1 <0.2',
'php-etl/pipeline-contracts:>=0.5.1 <0.6',
'php-etl/action-contracts:>=0.2.0 <0.3',
'php-etl/workflow:*',
);

Expand Down Expand Up @@ -325,7 +328,7 @@ private function compilePipelineJob(array $config): Satellite\Builder\Repository
$repository = new Satellite\Builder\Repository\Pipeline($pipeline);

$repository->addPackages(
'php-etl/pipeline-contracts:0.4.*',
'php-etl/pipeline-contracts:>=0.5.1 <0.6',
'php-etl/pipeline:*',
'php-etl/console-state:*',
'php-etl/pipeline-console-runtime:*',
Expand Down

0 comments on commit e7d4f07

Please sign in to comment.