如何为 Protocol Buffers rpc 方法定义空参数?

How to define empty parameter for Protocol Buffers rpc method?

我想定义一个名为 FindAll 的方法,它不需要任何参数。 ProtoC 正在抱怨。

预期的类型名称。

这适用于行:
rpc findAll () returns (BenchmarksList);

syntax = "proto3";

package helloWorldGRPC;

service HelloWorldGRPCService {
    rpc findById (BenchmarksById) returns (Benchmarks);
    rpc findAll () returns (BenchmarksList);
}

message BenchmarksById {
    string id = 1;
}

message BenchmarksList {
    repeated Benchmarks benchmarks = 1;
}

message Benchmarks {
    string trans_id = 1;
    string protocol = 2;
    string database = 3;
    string updated_at = 4;
    string created_at = 5;
    repeated Action actions = 6;
}

message Action {
    string trans_id = 1;
    int32 payload_length = 2;
    string payload = 3;
    string status = 4;
    string updated_at = 5;
    string created_at = 6;
}

首选方法是通过 Empty - 因为工具可以识别并针对该场景进行优化。但实际上,"special" 没有关于该类型的任何信息,任何消息——空的或其他的——都足够了。