Skip to content

Commit

Permalink
testing empty grpc requests
Browse files Browse the repository at this point in the history
  • Loading branch information
iWirk committed Jul 22, 2022
1 parent b5fd1dd commit 4ba47d5
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Console/Commands/TestGrpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
15 changes: 15 additions & 0 deletions bridge/Bridge/BridgeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
21 changes: 21 additions & 0 deletions bridge/Bridge/BridgeStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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
),
];
}

Expand Down
58 changes: 58 additions & 0 deletions bridge/Bridge/GetVersionReply.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions bridge/Bridge/GetVersionRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified bridge/GPBMetadata/Bridge.php
Binary file not shown.
56 changes: 56 additions & 0 deletions bridge/GetVersionReply.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions bridge/GetVersionRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ba47d5

Please sign in to comment.