rpc-no-client-streaming
Since 0.9.0 · In the rulesets: All at error
This rule checks whether any RPC uses client streaming.
Rule details
Client-streaming RPCs, whose request is declared with stream, are not supported by every
transport: gRPC-Web and most HTTP/JSON gateways, for example, cannot carry them. They are also
harder to retry, load-balance and debug than unary RPCs.
The rpc-no-client-streaming rule reports RPC '<rpc>' should not use client streaming for
every RPC with a streamed request, 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.
To allow a single RPC, add an // apigenie-lint-disable rpc-no-client-streaming comment to it.
Examples
Good.
syntax = "proto3";
package acme.pets.v1;
service PetService {
rpc UploadPhoto(UploadPhotoRequest) returns (UploadPhotoResponse);
}
message UploadPhotoRequest {
bytes photo = 1;
}
message UploadPhotoResponse {
string url = 1;
}
Bad. The linter reports RPC 'UploadPhotos' should not use client streaming.
syntax = "proto3";
package acme.pets.v1;
service PetService {
rpc UploadPhotos(stream UploadPhotosRequest) returns (UploadPhotosResponse);
}
message UploadPhotosRequest {
bytes photo = 1;
}
message UploadPhotosResponse {
repeated string urls = 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-client-streaming: off