diff --git a/composer.json b/composer.json index e56ad8b..f5a98ec 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ "suggest": { "ext-msgpack": "MessagePack codec support", "ext-protobuf": "Protobuf codec support", + "ext-swoole": "Swoole gocoroutine support", "rybakit/msgpack": "(^0.7) MessagePack codec support", "google/protobuf": "(^3.0) Protobuf codec support" }, diff --git a/src/RelayInterface.php b/src/RelayInterface.php index 209983c..27e7f96 100644 --- a/src/RelayInterface.php +++ b/src/RelayInterface.php @@ -21,4 +21,9 @@ public function waitFrame(): Frame; * @param Frame $frame */ public function send(Frame $frame): void; + + /** + * @return int + */ + public function getNextSeq(): int; } diff --git a/tests/Goridge/SwooleTest.php b/tests/Goridge/SwooleTest.php new file mode 100644 index 0000000..b9d9b32 --- /dev/null +++ b/tests/Goridge/SwooleTest.php @@ -0,0 +1,50 @@ + SWOOLE_HOOK_ALL]); + Co\run(function () { + $methods = [ + 'testManualConnect', + 'testReconnect', + 'testPingPong', + 'testPrefixPingPong', + 'testPingNull', + 'testNegate', + 'testNegateNegative', + 'testLongEcho', + 'testRawBody', + 'testPayload', + 'testPayloadWithMap', + + // 'testBrokenPayloadMap', + // 'testJsonException' + // 'testInvalidService', + // 'testInvalidMethod', + // 'testConvertException', + // 'testBadPayload', + + // 'testLongRawBody', + ]; + + foreach ($methods as $method) { + $barrier = Barrier::make(); + for ($i = 0; $i < 2; $i++) { + go(function () use ($barrier, $method) { + $this->$method(); + }); + } + Barrier::wait($barrier); + } + }); + } +} \ No newline at end of file