From a87669594bfc4039865e02eddada4a42c12110fc Mon Sep 17 00:00:00 2001 From: Vladimir Plakhotnikov Date: Fri, 31 May 2024 17:10:07 +0300 Subject: [PATCH 1/6] Added RR_VERSION env to Environment class Signed-off-by: Plakhotnikov Vladimir --- src/Environment.php | 12 +++++++++--- src/EnvironmentInterface.php | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Environment.php b/src/Environment.php index d1eef55..78ed0b7 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -9,9 +9,10 @@ /** * @psalm-import-type ModeType from Mode * @psalm-type EnvironmentVariables = array{ - * RR_MODE?: ModeType|string, - * RR_RELAY?: string, - * RR_RPC?: string, + * RR_MODE?: ModeType|string, + * RR_RELAY?: string, + * RR_RPC?: string, + * RR_VERSION?: string, * }|array * @see Mode */ @@ -40,6 +41,11 @@ public function getRPCAddress(): string return $this->get('RR_RPC', 'tcp://127.0.0.1:6001'); } + public function getVersion(): string + { + return $this->get('RR_VERSION', ''); + } + /** * @template TDefault of string * diff --git a/src/EnvironmentInterface.php b/src/EnvironmentInterface.php index 4219db9..81f8237 100644 --- a/src/EnvironmentInterface.php +++ b/src/EnvironmentInterface.php @@ -32,4 +32,9 @@ public function getRelayAddress(): string; * RPC address. */ public function getRPCAddress(): string; + + /** + * Roadrunner version + */ + public function getVersion(): string; } From 2438034774058fc7a27f8818dc6b27eb64ac30b3 Mon Sep 17 00:00:00 2001 From: Plakhotnikov Vladimir Date: Sat, 1 Jun 2024 10:46:47 +0300 Subject: [PATCH 2/6] Added RR_VERSION env to Environment class Signed-off-by: Plakhotnikov Vladimir --- tests/Unit/EnvironmentTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Unit/EnvironmentTest.php b/tests/Unit/EnvironmentTest.php index 93040cf..e5a5648 100644 --- a/tests/Unit/EnvironmentTest.php +++ b/tests/Unit/EnvironmentTest.php @@ -45,15 +45,23 @@ public function testGetRPCAddressWithValue(): void $this->assertEquals('rpc_value', $env->getRPCAddress()); } + public function testGetVersionWithValue(): void + { + $env = new Environment(['RR_VERSION' => '2024.1.3']); + $this->assertEquals('2024.1.3', $env->getVersion()); + } + public function testFromGlobals(): void { $_ENV['RR_MODE'] = 'global_mode'; $_SERVER['RR_RELAY'] = 'global_relay'; + $_SERVER['RR_VERSION'] = 'global_version'; $env = Environment::fromGlobals(); $this->assertEquals('global_mode', $env->getMode()); $this->assertEquals('global_relay', $env->getRelayAddress()); + $this->assertEquals('global_version', $env->getVersion()); $this->assertEquals('tcp://127.0.0.1:6001', $env->getRPCAddress()); } } \ No newline at end of file From 39bfd07560da564dab64f6e9ac59f747da592c7a Mon Sep 17 00:00:00 2001 From: Plakhotnikov Vladimir Date: Sat, 1 Jun 2024 18:13:19 +0300 Subject: [PATCH 3/6] Added RR_VERSION env to Environment class Signed-off-by: Plakhotnikov Vladimir --- src/Environment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Environment.php b/src/Environment.php index 78ed0b7..1af6963 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -28,7 +28,7 @@ public function __construct( public function getMode(): string { - return $this->get('RR_MODE', ''); + return $this->get('RR_MODE'); } public function getRelayAddress(): string @@ -43,7 +43,7 @@ public function getRPCAddress(): string public function getVersion(): string { - return $this->get('RR_VERSION', ''); + return $this->get('RR_VERSION'); } /** From c07921ddee928c624476f298f476228a9a697f04 Mon Sep 17 00:00:00 2001 From: Plakhotnikov Vladimir Date: Sat, 1 Jun 2024 18:13:37 +0300 Subject: [PATCH 4/6] Reformat Markdown tables Signed-off-by: Plakhotnikov Vladimir --- .github/ISSUE_TEMPLATE/1_Bug_report.md | 10 +++++----- .github/PULL_REQUEST_TEMPLATE.md | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.md b/.github/ISSUE_TEMPLATE/1_Bug_report.md index 5ea3ac3..4bbf5b7 100644 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.md +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.md @@ -14,10 +14,10 @@ labels: Bug ### Additional Info -| Q | A -|------------------| --- -| Package Version | x.y.z -| PHP version | x.y.z -| Operating system | Linux +| Q | A | +|------------------|-----------------------------------------------| +| Package Version | x.y.z | +| PHP version | x.y.z | +| Operating system | Linux | diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8c0643a..7d0c40e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,10 +1,10 @@ -| Q | A -| ------------- | --- -| Bugfix? | ✔️/❌ -| Breaks BC? | ✔️/❌ -| New feature? | ✔️/❌ -| Issues | #... -| Docs PR | spiral/docs#... +| Q | A | +|--------------|-------------------------------------------------------------------------------------------------------------------------| +| Bugfix? | ✔️/❌ | +| Breaks BC? | ✔️/❌ | +| New feature? | ✔️/❌ | +| Issues | #... | +| Docs PR | spiral/docs#... | From c81a6bbc5a8026607e680967664f3be54cb8b3fa Mon Sep 17 00:00:00 2001 From: Plakhotnikov Vladimir Date: Sat, 1 Jun 2024 18:14:02 +0300 Subject: [PATCH 5/6] Change return type of Worker::sendProcessId to void Signed-off-by: Plakhotnikov Vladimir --- src/Worker.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Worker.php b/src/Worker.php index ca7bd92..16a7281 100644 --- a/src/Worker.php +++ b/src/Worker.php @@ -276,11 +276,10 @@ public static function createFromEnvironment( ); } - private function sendProcessId(): static + private function sendProcessId(): void { $frame = new Frame($this->encode(['pid' => \getmypid()]), [], Frame::CONTROL); $this->sendFrame($frame); - return $this; } private function haveToPing(): void From b6170f871dcaa4e36fa578cfd44587f9279626dc Mon Sep 17 00:00:00 2001 From: Plakhotnikov Vladimir Date: Mon, 3 Jun 2024 15:48:06 +0300 Subject: [PATCH 6/6] Added RR_VERSION env to Environment class Signed-off-by: Plakhotnikov Vladimir --- src/EnvironmentInterface.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/EnvironmentInterface.php b/src/EnvironmentInterface.php index 81f8237..a659a45 100644 --- a/src/EnvironmentInterface.php +++ b/src/EnvironmentInterface.php @@ -12,6 +12,7 @@ * * @psalm-import-type ModeType from Mode * @see Mode + * @method string getVersion() */ interface EnvironmentInterface { @@ -32,9 +33,4 @@ public function getRelayAddress(): string; * RPC address. */ public function getRPCAddress(): string; - - /** - * Roadrunner version - */ - public function getVersion(): string; }