Skip to content
Merged
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
43 changes: 0 additions & 43 deletions config/autoload/templates.global.php

This file was deleted.

3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
colors="true"
>
colors="true">
<testsuites>
<testsuite name="default">
<directory>./test</directory>
Expand Down
20 changes: 5 additions & 15 deletions src/App/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Netglue\PsrContainer\Messenger\Container\Middleware\MessageHandlerMiddlewareStaticFactory;
use Netglue\PsrContainer\Messenger\Container\Middleware\MessageSenderMiddlewareStaticFactory;
use Netglue\PsrContainer\Messenger\HandlerLocator\OneToManyFqcnContainerHandlerLocator;
use Queue\App\Message\ExampleMessage;
use Queue\App\Message\ExampleMessageHandler;
use Queue\App\Message\Message;
use Queue\App\Message\MessageHandler;
use Symfony\Component\Messenger\MessageBusInterface;

class ConfigProvider
Expand All @@ -25,7 +25,6 @@ public function __invoke(): array
'buses' => $this->busConfig(),
],
],
'templates' => $this->getTemplates(),
];
}

Expand All @@ -37,23 +36,14 @@ private function getDependencies(): array
"message_bus_stamp_middleware" => [BusNameStampMiddlewareStaticFactory::class, "message_bus"],
"message_bus_sender_middleware" => [MessageSenderMiddlewareStaticFactory::class, "message_bus"],
"message_bus_handler_middleware" => [MessageHandlerMiddlewareStaticFactory::class, "message_bus"],
ExampleMessageHandler::class => AttributedServiceFactory::class,
MessageHandler::class => AttributedServiceFactory::class,
],
"aliases" => [
MessageBusInterface::class => "message_bus",
],
];
}

public function getTemplates(): array
{
return [
'paths' => [
'notification-email' => [__DIR__ . '/templates'],
],
];
}

private function busConfig(): array
{
return [
Expand Down Expand Up @@ -81,7 +71,7 @@ private function busConfig(): array
*/
'handler_locator' => OneToManyFqcnContainerHandlerLocator::class,
'handlers' => [
ExampleMessage::class => [ExampleMessageHandler::class],
Message::class => [MessageHandler::class],
],

/**
Expand All @@ -97,7 +87,7 @@ private function busConfig(): array
* Route specific messages to specific transports by using the message name as the key.
*/
'routes' => [
ExampleMessage::class => ["redis_transport"],
Message::class => ["redis_transport"],
],
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Queue\App\Message;

class ExampleMessage
class Message
{
public function __construct(
private array $payload,

Check notice on line 10 in src/App/Message/Message.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Property can be 'readonly'

Property can be 'readonly'

Check notice on line 10 in src/App/Message/Message.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Property can be 'readonly'

Property can be 'readonly'

Check notice on line 10 in src/App/Message/Message.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Property can be 'readonly'

Property can be 'readonly'
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Stamp\DelayStamp;

class ExampleMessageHandler
class MessageHandler
{
#[Inject(
MessageBusInterface::class,
Expand All @@ -24,7 +24,7 @@ public function __construct(
) {
}

public function __invoke(ExampleMessage $message): void
public function __invoke(Message $message): void
{
$payload = $message->getPayload();

Expand All @@ -50,21 +50,21 @@ public function __invoke(ExampleMessage $message): void
public function retry(array $payload): void
{
if (! isset($payload['retry'])) {
$this->bus->dispatch(new ExampleMessage(["foo" => $payload['foo'], 'retry' => 1]), [
$this->bus->dispatch(new Message(["foo" => $payload['foo'], 'retry' => 1]), [
new DelayStamp($this->config['fail-safe']['first_retry']),
]);
} else {
$retry = $payload['retry'];
switch ($retry) {
case 1:
$delay = $this->config['fail-safe']['second_retry'];
$this->bus->dispatch(new ExampleMessage(["foo" => $payload['foo'], 'retry' => ++$retry]), [
$this->bus->dispatch(new Message(["foo" => $payload['foo'], 'retry' => ++$retry]), [
new DelayStamp($delay),
]);
break;
case 2:
$delay = $this->config['fail-safe']['third_retry'];
$this->bus->dispatch(new ExampleMessage(["foo" => $payload['foo'], 'retry' => ++$retry]), [
$this->bus->dispatch(new Message(["foo" => $payload['foo'], 'retry' => ++$retry]), [
new DelayStamp($delay),
]);
break;
Expand Down
6 changes: 3 additions & 3 deletions src/Swoole/Delegators/TCPServerDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Queue\Swoole\Delegators;

use Psr\Container\ContainerInterface;
use Queue\App\Message\ExampleMessage;
use Queue\App\Message\Message;
use Queue\Swoole\Command\GetFailedMessagesCommand;
use Queue\Swoole\Command\GetProcessedMessagesCommand;
use Queue\Swoole\Command\GetQueuedMessagesCommand;
Expand Down Expand Up @@ -79,8 +79,8 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal
$logger->error("Error running command: " . $e->getMessage());
}
} else {
$bus->dispatch(new ExampleMessage(["foo" => $message]));
$bus->dispatch(new ExampleMessage(["foo" => "with 5 seconds delay"]), [
$bus->dispatch(new Message(["foo" => $message]));
$bus->dispatch(new Message(["foo" => "with 5 seconds delay"]), [
new DelayStamp(5000),
]);

Expand Down
Loading