From 4ba47d5ae7432a4f1595867f5c7d53d4d6a06f75 Mon Sep 17 00:00:00 2001 From: Saber Nouira Date: Fri, 22 Jul 2022 11:40:47 +0200 Subject: [PATCH] testing empty grpc requests --- app/Console/Commands/TestGrpc.php | 9 +++++ bridge/Bridge/BridgeClient.php | 15 +++++++ bridge/Bridge/BridgeStub.php | 21 ++++++++++ bridge/Bridge/GetVersionReply.php | 58 ++++++++++++++++++++++++++++ bridge/Bridge/GetVersionRequest.php | 31 +++++++++++++++ bridge/GPBMetadata/Bridge.php | Bin 649 -> 775 bytes bridge/GetVersionReply.php | 56 +++++++++++++++++++++++++++ bridge/GetVersionRequest.php | 56 +++++++++++++++++++++++++++ 8 files changed, 246 insertions(+) create mode 100644 bridge/Bridge/GetVersionReply.php create mode 100644 bridge/Bridge/GetVersionRequest.php create mode 100644 bridge/GetVersionReply.php create mode 100644 bridge/GetVersionRequest.php diff --git a/app/Console/Commands/TestGrpc.php b/app/Console/Commands/TestGrpc.php index 6fa59634..24a97f0c 100644 --- a/app/Console/Commands/TestGrpc.php +++ b/app/Console/Commands/TestGrpc.php @@ -3,6 +3,7 @@ namespace App\Console\Commands; use Bridge\BridgeClient; +use Bridge\GetVersionRequest; use Bridge\HelloRequest; use Illuminate\Console\Command; use Illuminate\Contracts\Filesystem\FileNotFoundException; @@ -69,6 +70,14 @@ public function handle(): int exit(1); } echo $response->getMessage() . PHP_EOL; + + $request2 = new GetVersionRequest(); + list($response2, $status2) = $client->GetVersion($request2)->wait(); + if ($status2->code !== \Grpc\STATUS_OK) { + echo "ERROR: " . $status2->code . ", " . $status2->details . PHP_EOL; + exit(1); + } + echo $response2->getVersion() . PHP_EOL; return 0; } } diff --git a/bridge/Bridge/BridgeClient.php b/bridge/Bridge/BridgeClient.php index 1470a611..d1e4c7f9 100644 --- a/bridge/Bridge/BridgeClient.php +++ b/bridge/Bridge/BridgeClient.php @@ -32,4 +32,19 @@ public function SayHello(\Bridge\HelloRequest $argument, $metadata, $options); } + /** + * Get the current version of the control panel + * @param \Bridge\GetVersionRequest $argument input argument + * @param array $metadata metadata + * @param array $options call options + * @return \Grpc\UnaryCall + */ + public function GetVersion(\Bridge\GetVersionRequest $argument, + $metadata = [], $options = []) { + return $this->_simpleRequest('/bridge.Bridge/GetVersion', + $argument, + ['\Bridge\GetVersionReply', 'decode'], + $metadata, $options); + } + } diff --git a/bridge/Bridge/BridgeStub.php b/bridge/Bridge/BridgeStub.php index 9021acb8..caeb19ca 100644 --- a/bridge/Bridge/BridgeStub.php +++ b/bridge/Bridge/BridgeStub.php @@ -23,6 +23,21 @@ public function SayHello( return null; } + /** + * Get the current version of the control panel + * @param \Bridge\GetVersionRequest $request client request + * @param \Grpc\ServerContext $context server request context + * @return \Bridge\GetVersionReply for response data, null if if error occured + * initial metadata (if any) and status (if not ok) should be set to $context + */ + public function GetVersion( + \Bridge\GetVersionRequest $request, + \Grpc\ServerContext $context + ): ?\Bridge\GetVersionReply { + $context->setStatus(\Grpc\Status::unimplemented()); + return null; + } + /** * Get the method descriptors of the service for server registration * @@ -37,6 +52,12 @@ public final function getMethodDescriptors(): array '\Bridge\HelloRequest', \Grpc\MethodDescriptor::UNARY_CALL ), + '/bridge.Bridge/GetVersion' => new \Grpc\MethodDescriptor( + $this, + 'GetVersion', + '\Bridge\GetVersionRequest', + \Grpc\MethodDescriptor::UNARY_CALL + ), ]; } diff --git a/bridge/Bridge/GetVersionReply.php b/bridge/Bridge/GetVersionReply.php new file mode 100644 index 00000000..39d44cb8 --- /dev/null +++ b/bridge/Bridge/GetVersionReply.php @@ -0,0 +1,58 @@ +bridge.GetVersionReply + */ +class GetVersionReply extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string version = 1; + */ + protected $version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $version + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Bridge::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string version = 1; + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * Generated from protobuf field string version = 1; + * @param string $var + * @return $this + */ + public function setVersion($var) + { + GPBUtil::checkString($var, True); + $this->version = $var; + + return $this; + } + +} + diff --git a/bridge/Bridge/GetVersionRequest.php b/bridge/Bridge/GetVersionRequest.php new file mode 100644 index 00000000..988ed5b2 --- /dev/null +++ b/bridge/Bridge/GetVersionRequest.php @@ -0,0 +1,31 @@ +bridge.GetVersionRequest + */ +class GetVersionRequest extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Bridge::initOnce(); + parent::__construct($data); + } + +} + diff --git a/bridge/GPBMetadata/Bridge.php b/bridge/GPBMetadata/Bridge.php index 3f1723b965766a153b17604b58f48bcc2a51a30a..d2ad5c3d03a5a47f98c8535bca04be05140f832c 100644 GIT binary patch delta 145 zcmeBVZD-rCl#yvR)8yrh!8S_5T!QYYC1I&W#hLkeL8*nMsl_EqN?iQNf(1F1Li}9p yWe`OYj0%hzoJK8-lm9R}*a|suaUs+SN$MpPWu~O3>LJ9ShDwQJN=-Ip3IPBmkuP5W delta 25 hcmZo?>tx-ql#yvJGetVersionReply + */ +class GetVersionReply extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string version = 1; + */ + protected $version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $version + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Updater::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string version = 1; + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * Generated from protobuf field string version = 1; + * @param string $var + * @return $this + */ + public function setVersion($var) + { + GPBUtil::checkString($var, True); + $this->version = $var; + + return $this; + } + +} + diff --git a/bridge/GetVersionRequest.php b/bridge/GetVersionRequest.php new file mode 100644 index 00000000..9860b067 --- /dev/null +++ b/bridge/GetVersionRequest.php @@ -0,0 +1,56 @@ +GetVersionRequest + */ +class GetVersionRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string version = 1; + */ + protected $version = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $version + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Updater::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string version = 1; + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * Generated from protobuf field string version = 1; + * @param string $var + * @return $this + */ + public function setVersion($var) + { + GPBUtil::checkString($var, True); + $this->version = $var; + + return $this; + } + +} +