# rpc-no-server-streaming

Source: https://api-genie.dev/docs/linter/protobuf/rules/rpc-no-server-streaming

A rule of the Protobuf linter, which reads proto3 files; the reader rejects proto2 and editions files. 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**.

```proto
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`.

```proto
syntax = "proto3";

package acme.pets.v1;

service PetService {
  rpc WatchPets(WatchPetsRequest) returns (stream WatchPetsResponse);
}

message WatchPetsRequest {
  string shelter = 1;
}

message WatchPetsResponse {
  string name = 1;
}
```
