Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include server streaming in rest descriptor #414

Merged
merged 2 commits into from Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Generation/MethodDetails.php
Expand Up @@ -536,6 +536,11 @@ public function isStreaming(): bool
$this->methodType === static::CLIENT_STREAMING;
}

public function isServerStreaming(): bool
{
return $this->methodType === static::SERVER_STREAMING;
}
noahdietz marked this conversation as resolved.
Show resolved Hide resolved

public function isMixin(): bool
{
return $this->mixinServiceFullname !== null;
Expand Down
2 changes: 1 addition & 1 deletion src/Generation/ResourcesGenerator.php
Expand Up @@ -210,7 +210,7 @@ public static function generateRestConfig(ServiceDetails $serviceDetails, Servic
private static function compileRestConfigInterfaces(ServiceDetails $serviceDetails, ServiceYamlConfig $serviceYamlConfig)
{
return $serviceDetails->methods
->filter(fn ($method) => !is_null($method->httpRule) && !$method->isStreaming() && !$method->isMixin())
->filter(fn ($method) => !is_null($method->httpRule) && ($method->isServerStreaming() || !$method->isStreaming()) && !$method->isMixin())
bshaffer marked this conversation as resolved.
Show resolved Hide resolved
->map(fn ($method) => [$serviceDetails->serviceName, $method, $method->httpRule])
->concat($serviceYamlConfig->httpRules->map(fn ($x) => [
Vector::new(explode('.', $x->getSelector()))->skipLast(1)->join('.'),
Expand Down
Expand Up @@ -4,13 +4,19 @@ package testing.basicserverstreaming;

option php_namespace = "Testing\\BasicServerStreaming";

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";

service BasicServerStreaming {
option (google.api.default_host) = "serverstreaming.example.com";

rpc MethodServer(Request) returns(stream Response);
rpc MethodServer(Request) returns(stream Response) {
option (google.api.http) = {
post: "/path:serverStreaming"
body: "*"
};
};

rpc MethodEmpty(EmptyRequest) returns(stream Response);
}
Expand Down
@@ -1,5 +1,13 @@
<?php

return [
'interfaces' => [],
'interfaces' => [
'testing.basicserverstreaming.BasicServerStreaming' => [
'MethodServer' => [
'method' => 'post',
'uriTemplate' => '/path:serverStreaming',
'body' => '*',
],
],
],
];