rpc-no-server-streaming
Since 0.9.0 · In the rulesets: All at error
This rule checks whether any RPC uses server streaming.
Rule details
Server-streaming RPCs, whose response is declared with stream, are not supported by every
transport: most HTTP/JSON gateways, for example, cannot carry them, and long-lived streams are
harder to load-balance and debug than unary RPCs.
The rpc-no-server-streaming rule reports RPC '<rpc>' should not use server streaming for
every RPC with a streamed response, including bidirectional streaming RPCs.
The rule is only part of the all ruleset.
Turn the rule off if all clients use a transport that supports streaming, such as gRPC over HTTP/2,
and some RPCs need to push updates. To allow a single RPC, add an // apigenie-lint-disable rpc-no-server-streaming comment to it.
Examples
Good.
syntax = "proto3";
package acme.pets.v1;
service PetService {
rpc ListPets(ListPetsRequest) returns (ListPetsResponse);
}
message ListPetsRequest {
int32 page_size = 1;
string page_token = 2;
}
message ListPetsResponse {
repeated string names = 1;
string next_page_token = 2;
}
Bad. The linter reports RPC 'WatchPets' should not use server streaming.
syntax = "proto3";
package acme.pets.v1;
service PetService {
rpc WatchPets(WatchPetsRequest) returns (stream WatchPetsResponse);
}
message WatchPetsRequest {
string shelter = 1;
}
message WatchPetsResponse {
string name = 1;
}
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.protobuf has the details.
commands:
lint:
protobuf:
rules:
rpc-no-server-streaming: off