Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the reason in the message publish to RabbitMQ #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Rejection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

use Bunny\Channel;
use Bunny\Client;
use Kiboko\Contract\Pipeline\RejectionInterface;
use Kiboko\Contract\Pipeline\StepCodeInterface;
use Kiboko\Contract\Pipeline\StepRejectionInterface;

final readonly class Rejection implements RejectionInterface
final readonly class Rejection implements StepRejectionInterface

Check failure on line 11 in src/Rejection.php

View workflow job for this annotation

GitHub Actions / phpstan-7

Class Kiboko\Component\Flow\RabbitMQ\Rejection implements generic interface Kiboko\Contract\Pipeline\StepRejectionInterface but does not specify its types: Type

Check failure on line 11 in src/Rejection.php

View workflow job for this annotation

GitHub Actions / phpstan-8

Class Kiboko\Component\Flow\RabbitMQ\Rejection implements generic interface Kiboko\Contract\Pipeline\StepRejectionInterface but does not specify its types: Type

Check failure on line 11 in src/Rejection.php

View workflow job for this annotation

GitHub Actions / phpstan-6

Class Kiboko\Component\Flow\RabbitMQ\Rejection implements generic interface Kiboko\Contract\Pipeline\StepRejectionInterface but does not specify its types: Type
{
private Channel $channel;

Expand All @@ -19,7 +18,7 @@
private string $topic,
private ?string $exchange = null,
) {
$this->channel = $this->connection->channel();

Check failure on line 21 in src/Rejection.php

View workflow job for this annotation

GitHub Actions / phpstan-7

Property Kiboko\Component\Flow\RabbitMQ\Rejection::$channel (Bunny\Channel) does not accept Bunny\Channel|React\Promise\PromiseInterface.
$this->channel->queueDeclare(
queue: $this->topic,
passive: false,
Expand All @@ -29,12 +28,6 @@
);
}

public function teardown(): void
{
$this->channel->close();
$this->connection->stop();
}

public static function withoutAuthentication(
string $stepUuid,
string $host,
Expand Down Expand Up @@ -77,7 +70,7 @@
return new self($connection, stepUuid: $stepUuid, topic: $topic, exchange: $exchange);
}

public function reject(StepCodeInterface $step, array|object $rejection, ?\Throwable $exception = null): void
public function reject(object|array $rejection, ?\Throwable $exception = null): void

Check failure on line 73 in src/Rejection.php

View workflow job for this annotation

GitHub Actions / phpstan-6

Method Kiboko\Component\Flow\RabbitMQ\Rejection::reject() has parameter $rejection with no value type specified in iterable type array.
{
$this->channel->publish(
\json_encode([
Expand All @@ -93,11 +86,12 @@
);
}

public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, ?\Throwable $exception = null): void
public function rejectWithReason(object|array $rejection, string $reason, ?\Throwable $exception = null): void

Check failure on line 89 in src/Rejection.php

View workflow job for this annotation

GitHub Actions / phpstan-6

Method Kiboko\Component\Flow\RabbitMQ\Rejection::rejectWithReason() has parameter $rejection with no value type specified in iterable type array.
{
$this->channel->publish(
\json_encode([
'item' => $rejection,
'reason' => $reason,
'exception' => $exception,
'step' => $this->stepUuid,
], \JSON_THROW_ON_ERROR),
Expand All @@ -119,4 +113,10 @@
autoDelete: true,
);
}

public function teardown(): void
{
$this->channel->close();
$this->connection->stop();
}
}
3 changes: 2 additions & 1 deletion src/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
private readonly StateManager $manager,
private readonly string $stepCode,
private readonly string $stepLabel,
) {}
) {
}

public function accept(int $count = 1): void
{
Expand All @@ -39,7 +40,7 @@
$this->manager->trySend($this->stepCode);
}

public function toArray(): array

Check failure on line 43 in src/State.php

View workflow job for this annotation

GitHub Actions / phpstan-6

Method Kiboko\Component\Flow\RabbitMQ\State::toArray() return type has no value type specified in iterable type array.
{
return [
'code' => $this->stepCode,
Expand Down
Loading