From 21863e8de6761d4a94dddfd44df98201232d2fd3 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 12 Jan 2023 19:26:36 +0100 Subject: [PATCH] Add support to load openswoole-specific config via env vars --- CHANGELOG.md | 2 ++ composer.json | 2 +- config/autoload/swoole.global.php | 3 +++ module/Core/test/Config/NotFoundRedirectResolverTest.php | 2 +- module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php | 2 +- module/Rest/test/Middleware/AuthenticationMiddlewareTest.php | 2 +- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7389d9d..a7a45727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this The status 308 is equivalent to 301, and 307 is equivalent to 302. The difference is that the spec requires the client to respect the original HTTP method when performing the redirect. With 301 and 302, some old clients might perform a `GET` request during the redirect, regardless the original request method. +* [#1662](https://github.com/shlinkio/shlink/issues/1662) Added support to provide openswoole-specific config options via env vars prefixed with `OPENSWOOLE_`. + ### Changed * *Nothing* diff --git a/composer.json b/composer.json index a3b90d76..85608742 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "pugx/shortid-php": "^1.1", "ramsey/uuid": "^4.5", "shlinkio/shlink-common": "^5.2", - "shlinkio/shlink-config": "^2.3", + "shlinkio/shlink-config": "dev-main#2a5b5c2 as 2.4", "shlinkio/shlink-event-dispatcher": "^2.6", "shlinkio/shlink-importer": "^5.0", "shlinkio/shlink-installer": "dev-develop#5fcee9b as 8.3", diff --git a/config/autoload/swoole.global.php b/config/autoload/swoole.global.php index 36cba24f..494e3cf2 100644 --- a/config/autoload/swoole.global.php +++ b/config/autoload/swoole.global.php @@ -4,6 +4,8 @@ declare(strict_types=1); use Shlinkio\Shlink\Core\Config\EnvVars; +use function Shlinkio\Shlink\Config\getOpenswooleConfigFromEnv; + use const Shlinkio\Shlink\MIN_TASK_WORKERS; return (static function (): array { @@ -21,6 +23,7 @@ return (static function (): array { 'process-name' => 'shlink', 'options' => [ + ...getOpenswooleConfigFromEnv(), 'worker_num' => (int) EnvVars::WEB_WORKER_NUM->loadFromEnv(16), 'task_worker_num' => max($taskWorkers, MIN_TASK_WORKERS), ], diff --git a/module/Core/test/Config/NotFoundRedirectResolverTest.php b/module/Core/test/Config/NotFoundRedirectResolverTest.php index d2d03807..4ffa0024 100644 --- a/module/Core/test/Config/NotFoundRedirectResolverTest.php +++ b/module/Core/test/Config/NotFoundRedirectResolverTest.php @@ -135,7 +135,7 @@ class NotFoundRedirectResolverTest extends TestCase RouteResult::class, RouteResult::fromRoute( new Route( - '', + 'foo', $this->createMock(MiddlewareInterface::class), ['GET'], $routeName, diff --git a/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php b/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php index aa6302a3..800dc4e0 100644 --- a/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php +++ b/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php @@ -55,7 +55,7 @@ class NotFoundTemplateHandlerTest extends TestCase RouteResult::class, RouteResult::fromRoute( new Route( - '', + 'foo', $this->createMock(MiddlewareInterface::class), ['GET'], RedirectAction::class, diff --git a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php index 3eb77dcb..62ca5aef 100644 --- a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php +++ b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php @@ -95,7 +95,7 @@ class AuthenticationMiddlewareTest extends TestCase { $baseRequest = fn (string $routeName) => ServerRequestFactory::fromGlobals()->withAttribute( RouteResult::class, - RouteResult::fromRoute(new Route($routeName, $this->getDummyMiddleware()), []), + RouteResult::fromRoute(new Route($routeName, $this->getDummyMiddleware())), // @phpstan-ignore-line ); $apiKeyMessage = 'Expected one of the following authentication headers, ["X-Api-Key"], but none were provided'; $queryMessage = 'Expected authentication to be provided in "apiKey" query param';