Skip to content

Commit

Permalink
feat: include server streaming in rest descriptor (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz committed Nov 30, 2021
1 parent 10866d8 commit f5f6060
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
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;
}

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())
->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' => '*',
],
],
],
];

0 comments on commit f5f6060

Please sign in to comment.