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 3f1723b9..d2ad5c3d 100644 Binary files a/bridge/GPBMetadata/Bridge.php and b/bridge/GPBMetadata/Bridge.php differ diff --git a/bridge/GetVersionReply.php b/bridge/GetVersionReply.php new file mode 100644 index 00000000..d4d3036c --- /dev/null +++ b/bridge/GetVersionReply.php @@ -0,0 +1,56 @@ +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\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; + } + +} +