Skip to content

Commit

Permalink
Merge pull request #110 from Baldinof/rr-2023
Browse files Browse the repository at this point in the history
Allow RoadRunner 2023.x
  • Loading branch information
Baldinof authored May 17, 2023
2 parents 0c25061 + fb3cff1 commit ffdda06
Show file tree
Hide file tree
Showing 39 changed files with 4,395 additions and 868 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: CI
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
Expand All @@ -12,7 +11,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0', '8.1', '8.2']
php-versions: ['8.1', '8.2']
composer:
- {name: "lowest", flags: " --prefer-dist --prefer-lowest"}
- {name: "stable", flags: " --prefer-dist --prefer-stable"}
Expand All @@ -26,7 +25,9 @@ jobs:
extensions: mbstring,intl,mongodb-mongodb/mongo-php-driver@master
tools: composer:v2
- name: Install dependencies
run: composer update ${{ matrix.composer.flags }}
run: |
composer update ${{ matrix.composer.flags }}
cd tools && composer install
- name: PHPUnit
run: composer test

Expand All @@ -37,7 +38,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0', '8.1', '8.2']
php-versions: ['8.1', '8.2']
composer:
- {name: "lowest", flags: " --prefer-dist --prefer-lowest"}
- {name: "stable", flags: " --prefer-dist --prefer-stable"}
Expand All @@ -51,7 +52,9 @@ jobs:
extensions: mbstring,intl,mongodb
tools: composer:v2
- name: Install dependencies
run: composer update ${{ matrix.composer.flags }}
run: |
composer update ${{ matrix.composer.flags }}
cd tools && composer install
- name: PHPStan
run: composer phpstan

Expand All @@ -64,7 +67,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
extensions: mbstring,intl,mongodb
tools: composer:v2
- name: Get composer cache directory
Expand All @@ -77,6 +80,8 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist
run: |
composer update ${{ matrix.composer.flags }}
cd tools && composer install
- name: PHP CS Fixer
run: composer cs:lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/tests/__cache
/.phpunit.result.cache
/.php-cs-fixer.cache
/tools/vendor
16 changes: 3 additions & 13 deletions .rr.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
version: "2.7"
version: "3"

server:
command: "php public/index.php"
# If you are not using symfony 5.3+ and the new Runtime component:
# remove the previous `command` line above and uncomment the line below to use the deprecated command.
# command: "php bin/console baldinof:roadrunner:worker"
env:
- APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime

http:
address: 0.0.0.0:8080
middleware: [ "static", "gzip" ]
pool:
debug: true
uploads:
forbid: [ ".php", ".exe", ".bat" ]
static:
Expand All @@ -27,12 +26,3 @@ logs:
mode: raw
metrics:
level: debug

reload:
enabled: true
interval: 1s
patterns: [".php", ".yaml"]
services:
http:
dirs: ["."]
recursive: true
7 changes: 3 additions & 4 deletions .rr.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
version: "2.7"
version: "3"

server:
command: "php public/index.php"
# If you are not using symfony 5.3+ and the new Runtime component:
# remove the previous `command` line above and uncomment the line below to use the deprecated command.
# command: "php bin/console baldinof:roadrunner:worker"
env:
- APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime

http:
address: 0.0.0.0:8080
pool:
debug: false
middleware: [ "static", "gzip" ]
uploads:
forbid: [ ".php", ".exe", ".bat" ]
Expand Down
49 changes: 23 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,49 @@
}
},
"require": {
"php": ">=7.4",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0",
"symfony/yaml": "^4.4 || ^5.0 || ^6.0",
"spiral/roadrunner": "^2.0.2",
"spiral/roadrunner-worker": "^2.1.4",
"spiral/goridge": "^3.0",
"symfony/psr-http-message-bridge": "^1.1 || ^2.0",
"psr/log": "^1.1 || ^2.0 || ^3.0"
"php": ">=8.1",
"symfony/config": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/yaml": "^6.0",
"spiral/roadrunner": "^2023.1.0",
"spiral/roadrunner-worker": "^3.0.0",
"spiral/goridge": "^4.0",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"spiral/roadrunner-http": "^3.0"
},
"suggest": {
"nyholm/psr7": "For a super lightweight PSR-7/17 implementation",
"symfony/proxy-manager-bridge": "For doctrine re-connection implementation"
},
"require-dev": {
"symfony/var-dumper": "^4.0 || ^5.0 || ^6.0",
"phpunit/phpunit": "^9.5",
"phpspec/prophecy": "^1.11",
"phpspec/prophecy-phpunit": "^2.0",
"friendsofphp/php-cs-fixer": "^3.4",
"phpstan/phpstan": "^1.2",
"symfony/var-dumper": "^6.0",
"sentry/sentry-symfony": "^4.5",
"symfony/framework-bundle": "^4.0 || ^5.0 || ^6.0",
"symfony/framework-bundle": "^6.0",
"nyholm/psr7": "^1.2",
"doctrine/mongodb-odm": "^2.2",
"blackfire/php-sdk": "^1.21",
"doctrine/doctrine-bundle": "^2.1.1",
"doctrine/orm": "^2.7.3",
"symfony/proxy-manager-bridge": "^4.0 || ^5.0 || ^6.0",
"spiral/roadrunner-metrics": "^2.0.1",
"symfony/proxy-manager-bridge": "^6.0",
"symfony/validator": "^6.0",
"spiral/roadrunner-metrics": "^3.0.0",
"mikey179/vfsstream": "^1.6.8",
"symfony/runtime": "^5.3.0 || ^6.0",
"symfony/runtime": "^6.0",
"symfony/var-exporter": "^6.2",
"laminas/laminas-zendframework-bridge": "^1.4",
"spiral/roadrunner-grpc": "^2.0"
"spiral/roadrunner-grpc": "^3.0.0"
},
"conflict": {
"doctrine/doctrine-bundle": "<2.1.1",
"sentry/sentry-symfony": "<4.5.0",
"spiral/roadrunner-metrics": "<2.0.1"
"spiral/roadrunner-metrics": "<3.0.0"
},
"scripts": {
"test": "phpunit --testdox --colors=always",
"phpstan": "phpstan analyse --no-progress --ansi",
"cs:lint": "php-cs-fixer fix --dry-run --diff --ansi --allow-risky=yes",
"cs:fix": "php-cs-fixer fix --ansi --allow-risky=yes",
"test": "tools/vendor/bin/phpunit --testdox --colors=always",
"phpstan": "tools/vendor/bin/phpstan analyse --no-progress --ansi",
"cs:lint": "tools/vendor/bin/php-cs-fixer fix --dry-run --diff --ansi --allow-risky=yes",
"cs:fix": "tools/vendor/bin/php-cs-fixer fix --ansi --allow-risky=yes",
"ci": [
"@test", "@phpstan", "@cs:lint"
]
Expand Down
32 changes: 2 additions & 30 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Baldinof\RoadRunnerBundle\Command\WorkerCommand;
use Baldinof\RoadRunnerBundle\DependencyInjection\BaldinofRoadRunnerExtension;
use Baldinof\RoadRunnerBundle\Grpc\GrpcServiceProvider;
use Baldinof\RoadRunnerBundle\Helpers\RPCFactory;
use Baldinof\RoadRunnerBundle\Http\KernelHandler;
use Baldinof\RoadRunnerBundle\Http\MiddlewareStack;
use Baldinof\RoadRunnerBundle\Http\RequestHandlerInterface;
use Baldinof\RoadRunnerBundle\Integration\PHP\NativeSessionMiddleware;
use Baldinof\RoadRunnerBundle\Integration\Symfony\StreamedResponseListener;
use Baldinof\RoadRunnerBundle\Reboot\KernelRebootStrategyInterface;
use Baldinof\RoadRunnerBundle\RoadRunnerBridge\HttpFoundationWorker;
use Baldinof\RoadRunnerBundle\RoadRunnerBridge\HttpFoundationWorkerInterface;
use Baldinof\RoadRunnerBundle\Worker\GrpcWorker as InternalGrpcWorker;
use Baldinof\RoadRunnerBundle\Worker\GrpcWorkerInterface;
use Baldinof\RoadRunnerBundle\Worker\HttpDependencies;
use Baldinof\RoadRunnerBundle\Worker\HttpWorker as InternalHttpWorker;
use Baldinof\RoadRunnerBundle\Worker\WorkerRegistry;
Expand All @@ -38,14 +34,6 @@
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

// Polyfill of the `service()` function introduced in Symfony 5.1 when using older version
if (!\function_exists('Symfony\Component\DependencyInjection\Loader\Configurator\service')) {
function service(string $id): ReferenceConfigurator
{
return ref($id); // @phpstan-ignore-line
}
}

return static function (ContainerConfigurator $container) {
$container->parameters()
->set('baldinof_road_runner.intercept_side_effect', true);
Expand Down Expand Up @@ -101,10 +89,6 @@ function service(string $id): ReferenceConfigurator
service(EventDispatcherInterface::class),
]);

$services->set(WorkerCommand::class)
->args([service(InternalHttpWorker::class)])
->autoconfigure();

$services->set(KernelHandler::class)
->args([
service('kernel'),
Expand All @@ -115,18 +99,6 @@ function service(string $id): ReferenceConfigurator

$services->alias(RequestHandlerInterface::class, MiddlewareStack::class);

$services->set(NativeSessionMiddleware::class);

// @phpstan-ignore-next-line - PHPStan says this is always true, but the constant value depends on the currently installed Symfony version
if (Kernel::VERSION_ID < 60100) {
$services->set(StreamedResponseListener::class)
->decorate('streamed_response_listener')
->args([
service(StreamedResponseListener::class.'.inner'),
'%env(default::RR_MODE)%',
]);
}

if (interface_exists(GrpcServiceInterface::class)) {
$services->set(GrpcServiceProvider::class);
$services->set(GrpcInvoker::class);
Expand All @@ -136,7 +108,7 @@ function service(string $id): ReferenceConfigurator
service(GrpcInvoker::class),
]);

$services->set(GrpcWorkerInterface::class, InternalGrpcWorker::class)
$services->set(InternalGrpcWorker::class)
->public() // Manually retrieved on the DIC in the Worker if the kernel has been rebooted
->tag('monolog.logger', ['channel' => BaldinofRoadRunnerExtension::MONOLOG_CHANNEL])
->args([
Expand All @@ -150,7 +122,7 @@ function service(string $id): ReferenceConfigurator
->get(WorkerRegistryInterface::class)
->call('registerWorker', [
Environment\Mode::MODE_GRPC,
service(GrpcWorkerInterface::class),
service(InternalGrpcWorker::class),
]);
}
};
72 changes: 0 additions & 72 deletions src/Command/WorkerCommand.php

This file was deleted.

7 changes: 0 additions & 7 deletions src/DependencyInjection/BaldinofRoadRunnerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Baldinof\RoadRunnerBundle\Integration\Blackfire\BlackfireMiddleware;
use Baldinof\RoadRunnerBundle\Integration\Doctrine\DoctrineODMListener;
use Baldinof\RoadRunnerBundle\Integration\Doctrine\DoctrineORMMiddleware;
use Baldinof\RoadRunnerBundle\Integration\PHP\NativeSessionMiddleware;
use Baldinof\RoadRunnerBundle\Integration\Sentry\SentryListener;
use Baldinof\RoadRunnerBundle\Integration\Sentry\SentryMiddleware;
use Baldinof\RoadRunnerBundle\Integration\Sentry\SentryTracingRequestListenerDecorator;
Expand All @@ -34,7 +33,6 @@
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class BaldinofRoadRunnerExtension extends Extension
Expand Down Expand Up @@ -177,11 +175,6 @@ private function loadIntegrations(ContainerBuilder $container, array $config): v
$beforeMiddlewares[] = DoctrineORMMiddleware::class;
}

// @phpstan-ignore-next-line - PHPStan says this is always true, but the constant value depends on the currently installed Symfony version
if (Kernel::VERSION_ID < 50400) {
$beforeMiddlewares[] = NativeSessionMiddleware::class;
}

$container->setParameter('baldinof_road_runner.middlewares.default', ['before' => $beforeMiddlewares, 'after' => $lastMiddlewares]);
}

Expand Down
Loading

0 comments on commit ffdda06

Please sign in to comment.