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
7 changes: 6 additions & 1 deletion .docker/velox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ repository = "tcp"
[github.plugins.smtp-server]
ref = "2.0.0"
owner = "buggregator"
repository = "smtp-server"
repository = "smtp-server"

[github.plugins.var-dumper-server]
ref = "1.0.0"
owner = "buggregator"
repository = "var-dumper-server"
37 changes: 14 additions & 23 deletions .rr-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,26 @@ server:
command: "php app.php register:modules"

logs:
# Logging mode can be "development", "production" or "raw".
# Do not forget to change this value for production environment.
mode: ${RR_LOG_MODE:-production}
# Encoding format can be "console" or "json" (last is preferred for production usage).
encoding: ${RR_LOG_ENCODING:-json}
# Logging level can be "panic", "error", "warn", "info", "debug".
level: ${RR_LOG_LEVEL:-warn}
channels:
http:
# HTTP plugin logging level can be "panic", "error", "warn", "info", "debug".
level: ${RR_LOG_HTTP_LEVEL:-warn}
tcp:
# TCP plugin logging level can be "panic", "error", "warn", "info", "debug".
level: ${RR_LOG_TCP_LEVEL:-warn}
jobs:
# JOBS plugin logging level can be "panic", "error", "warn", "info", "debug".
level: ${RR_LOG_JOBS_LEVEL:-warn}
centrifuge:
# Centrifuge plugin logging level can be "panic", "error", "warn", "info", "debug".
level: ${RR_LOG_CENTRIFUGE_LEVEL:-warn}
server:
# Server logging level can be "panic", "error", "warn", "info", "debug".
level: ${RR_LOG_SERVER_LEVEL:-warn}
service:
# Service logging level can be "panic", "error", "warn", "info", "debug".
level: ${RR_LOG_SERVICE_LEVEL:-warn}
smtp:
level: ${RR_LOG_SMTP_LEVEL:-warn}
var-dumper:
level: ${RR_LOG_VAR_DUMPER_LEVEL:-warn}

http:
address: 127.0.0.1:8082
Expand All @@ -57,20 +51,11 @@ http:
tcp:
servers:
monolog:
# Address to listen.
addr: ${RR_TCP_MONOLOG_ADDR:-:9913}
delimiter: "\n"
var-dumper:
# Address to listen.
addr: ${RR_TCP_VAR_DUMPER_ADDR:-:9912}
delimiter: "\n"
# Chunks that RR uses to read the data. In bytes.
# If you expect big payloads on a TCP server, to reduce `read` syscalls,
# would be a good practice to use a fairly big enough buffer.
# Default: 1024 * 1024 * 50 (50MB)
read_buf_size: ${RR_TCP_READ_BUF_SIZE:-50485760}
pool:
num_workers: ${RR_TCP_NUM_WORKERS:-2}
num_workers: ${RR_TCP_NUM_WORKERS:-1}

kv:
local:
Expand All @@ -79,9 +64,9 @@ kv:

jobs:
consume:
- smtp
- events
pipelines:
smtp:
events:
driver: memory
config:
priority: 10
Expand All @@ -93,7 +78,13 @@ smtp:
addr: ${RR_SMTP_ADDR:-:1025}
hostname: "buggregator.local"
jobs:
pipeline: smtp
pipeline: events

var-dumper:
addr: ${RR_VAR_DUMPER_ADDR:-:9912}
max_message_size: ${RR_TCP_READ_BUF_SIZE:-50485760}
jobs:
pipeline: events

service:
nginx:
Expand Down
2 changes: 2 additions & 0 deletions app/config/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Modules\Smtp\Interfaces\Jobs\EmailHandler;
use Modules\VarDumper\Interfaces\Jobs\DumpHandler;
use Modules\Webhooks\Interfaces\Job\WebhookHandler;
use Spiral\Queue\Driver\SyncDriver;
use Spiral\RoadRunner\Jobs\Queue\MemoryCreateInfo;
Expand Down Expand Up @@ -39,6 +40,7 @@
'registry' => [
'handlers' => [
'smtp.email' => EmailHandler::class,
'vardumper.dump' => DumpHandler::class,
],
'serializers' => [
WebhookHandler::class => 'symfony-json',
Expand Down
2 changes: 0 additions & 2 deletions app/config/tcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
declare(strict_types=1);

use App\Application\TCP\ExceptionHandlerInterceptor;
use Modules\VarDumper\Interfaces\TCP\Service as VarDumperService;
use Modules\Monolog\Interfaces\TCP\Service as MonologService;

return [
'services' => [
'var-dumper' => VarDumperService::class,
'monolog' => MonologService::class,
],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Modules\VarDumper\Interfaces\TCP;
namespace Modules\VarDumper\Interfaces\Jobs;

use App\Application\Commands\HandleReceivedEvent;
use Modules\VarDumper\Application\Dump\BodyInterface;
Expand All @@ -12,41 +12,32 @@
use Modules\VarDumper\Application\Dump\MessageParser;
use Modules\VarDumper\Application\Dump\ParsedPayload;
use Modules\VarDumper\Application\Dump\PrimitiveBody;
use Spiral\Core\InvokerInterface;
use Spiral\Cqrs\CommandBusInterface;
use Spiral\RoadRunner\Tcp\Request;
use Spiral\RoadRunner\Tcp\TcpEvent;
use Spiral\RoadRunnerBridge\Tcp\Response\ContinueRead;
use Spiral\RoadRunnerBridge\Tcp\Response\ResponseInterface;
use Spiral\RoadRunnerBridge\Tcp\Service\ServiceInterface;
use Spiral\Queue\JobHandler;
use Symfony\Component\VarDumper\Cloner\Data;

final readonly class Service implements ServiceInterface
final class DumpHandler extends JobHandler
{
public function __construct(
private CommandBusInterface $commandBus,
private DumpIdGeneratorInterface $dumpId,
) {}
private readonly CommandBusInterface $bus,
private readonly DumpIdGeneratorInterface $dumpId,
InvokerInterface $invoker,
) {
parent::__construct($invoker);
}

public function handle(Request $request): ResponseInterface
public function invoke(mixed $payload): void
{
if ($request->event === TcpEvent::Connected) {
return new ContinueRead();
}

$messages = \array_filter(\explode("\n", $request->body));

foreach ($messages as $message) {
$payload = (new MessageParser())->parse($message);

$this->fireEvent($payload);
}

return new ContinueRead();
$this->fireEvent(
(new MessageParser())->parse($payload),
);
}


private function fireEvent(ParsedPayload $payload): void
{
$this->commandBus->dispatch(
$this->bus->dispatch(
new HandleReceivedEvent(
type: 'var-dump',
payload: [
Expand Down Expand Up @@ -96,4 +87,5 @@ private function prepareContent(ParsedPayload $payload): array

return $payloadContent;
}

}
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
args:
GH_TOKEN: "${GH_TOKEN}"
environment:
# RR_LOG_LEVEL: debug
RR_LOG_LEVEL: debug
# RR_LOG_TCP_LEVEL: debug
# RR_LOG_JOBS_LEVEL: debug
# RR_LOG_SERVER_LEVEL: debug
Expand Down
35 changes: 0 additions & 35 deletions tests/Feature/Interfaces/TCP/TCPTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
namespace Tests\Feature\Interfaces\TCP;

use Modules\Monolog\Interfaces\TCP\Service as MonologService;
use Modules\VarDumper\Interfaces\TCP\Service as VarDumperService;
use Modules\Smtp\Interfaces\TCP\Service as SmtpService;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
use Spiral\RoadRunner\Tcp\Request;
use Spiral\RoadRunner\Tcp\TcpEvent;
use Spiral\RoadRunnerBridge\Tcp\Response\ResponseInterface;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Tests\App\Smtp\FakeStream;
use Tests\DatabaseTestCase;

abstract class TCPTestCase extends DatabaseTestCase
Expand All @@ -25,20 +19,6 @@ public function handleMonologRequest(string $message): ResponseInterface
->handle($this->buildRequest(message: $message));
}

public function handleVarDumperRequest(string $message): ResponseInterface
{
return $this
->get(VarDumperService::class)
->handle($this->buildRequest(message: $message));
}

public function handleSmtpRequest(string $message, TcpEvent $event = TcpEvent::Data): ResponseInterface
{
return $this
->get(SmtpService::class)
->handle($this->buildRequest(message: $message, event: $event));
}

private function buildRequest(string $message, TcpEvent $event = TcpEvent::Data): Request
{
return new Request(
Expand All @@ -49,19 +29,4 @@ private function buildRequest(string $message, TcpEvent $event = TcpEvent::Data)
server: 'localhost',
);
}

protected function buildSmtpClient(string $username = 'homestead', ?UuidInterface $uuid = null): EsmtpTransport
{
$client = new EsmtpTransport(
stream: new FakeStream(
service: $this->get(SmtpService::class),
uuid: (string) $uuid ?? Uuid::uuid7(),
),
);

$client->setUsername($username);
$client->setPassword('password');

return $client;
}
}
35 changes: 0 additions & 35 deletions tests/Feature/Interfaces/TCP/VarDumper/SymfonyV6Test.php

This file was deleted.

Loading
Loading