Skip to content

Commit dd5c344

Browse files
committed
Updated dependencies and fixed State class
1 parent 1d6cb5d commit dd5c344

File tree

3 files changed

+31
-74
lines changed

3 files changed

+31
-74
lines changed

composer.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,17 @@
3232
"prefer-stable": true,
3333
"require": {
3434
"php": "^8.0",
35-
"psr/log": "^1.1@dev",
3635
"php-etl/pipeline-contracts": "^0.3.0",
37-
"php-etl/bucket": "^0.2.0",
38-
"bunny/bunny": "@dev"
36+
"php-etl/bucket": "dev-feature/update-bucket-contracts as 0.2.0",
37+
"bunny/bunny": "^0.5.0"
3938
},
4039
"require-dev": {
4140
"phpunit/phpunit": "^9.0",
4241
"phpunit/php-invoker": "*",
4342
"johnkary/phpunit-speedtrap": "*",
4443
"mybuilder/phpunit-accelerator": "*",
4544
"infection/infection": "^0.20",
46-
"adlawson/vfs": "dev-develop",
47-
"php-etl/phpunit-extension": "*"
45+
"adlawson/vfs": "dev-develop"
4846
},
4947
"extra": {
5048
"branch-alias": {

composer.lock

Lines changed: 17 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/State.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ final class State implements StateInterface
1313

1414
public function __construct(
1515
private Client $connection,
16+
private string $pipelineId,
1617
private string $stepCode,
1718
private string $stepLabel,
1819
private string $topic,
@@ -22,6 +23,7 @@ public function __construct(
2223
}
2324

2425
public static function withoutAuthentication(
26+
string $pipelineId,
2527
string $stepCode,
2628
string $stepLabel,
2729
string $host,
@@ -39,10 +41,11 @@ public static function withoutAuthentication(
3941
]);
4042
$connection->connect();
4143

42-
return new self($connection, stepCode: $stepCode, stepLabel: $stepLabel, topic: $topic, exchange: $exchange);
44+
return new self($connection, pipelineId: $pipelineId, stepCode: $stepCode, stepLabel: $stepLabel, topic: $topic, exchange: $exchange);
4345
}
4446

4547
public static function withAuthentication(
48+
string $pipelineId,
4649
string $stepCode,
4750
string $stepLabel,
4851
string $host,
@@ -62,14 +65,15 @@ public static function withAuthentication(
6265
]);
6366
$connection->connect();
6467

65-
return new self($connection, stepCode: $stepCode, stepLabel: $stepLabel, topic: $topic, exchange: $exchange);
68+
return new self($connection, pipelineId: $pipelineId, stepCode: $stepCode, stepLabel: $stepLabel, topic: $topic, exchange: $exchange);
6669
}
6770

6871
public function initialize(int $start = 0): void
6972
{
7073
$this->metrics = [
7174
'accept' => 0,
7275
'reject' => 0,
76+
'error' => 0,
7377
];
7478

7579
$this->channel->queueDeclare(
@@ -97,7 +101,9 @@ public function reject(int $step = 1): void
97101

98102
public function error(int $step = 1): void
99103
{
100-
// Not implemented yet
104+
$this->metrics['error'] += $step;
105+
106+
$this->sendMessage('error');
101107
}
102108

103109
public function teardown(): void
@@ -112,7 +118,7 @@ private function sendMessage(string $metricCode): void
112118

113119
$this->channel->publish(
114120
\json_encode([
115-
'id' => '',
121+
'id' => $this->pipelineId,
116122
'date' => ['date' => $date->format('c'), 'tz' => $date->getTimezone()->getName()],
117123
'stepsUpdates' => [
118124
[
@@ -121,7 +127,7 @@ private function sendMessage(string $metricCode): void
121127
'metrics' => [
122128
[
123129
'code' => $metricCode,
124-
'increment' => $step
130+
'increment' => $this->metrics[$metricCode]
125131
]
126132
]
127133
]

0 commit comments

Comments
 (0)