Linter rulesProtobufrpc-no-client-streaming

rpc-no-client-streaming

Since 0.9.0

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.

Configuration

This rule has no options.

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;
}

When Not to Use It

You may disable this rule 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.

Compatibility

This rule is compatible with proto3 files. proto2 and editions files are rejected by the reader and are not linted.

Related rules