Protobuf 是否支持元组?

Does Protobuf support Tuples?

我想从 grpc 服务器流式传输一个字符串元组。

我似乎找不到一个聪明的方法(如果有的话)来完成这件事。你们有没有在 Protobuf 中使用过元组?

附加信息:

我正在使用 F#,想要相应的东西

string * string

你用的是什么库?我用 protobuf-net.Grpc 没问题。我的服务如下所示:

member __.SubscribeTupleAsync() =
    asyncSeq {
        while true do
            let time = DateTime.Now
            yield string time.Minute, string time.Second
            do! Async.Sleep 1000
    } |> AsyncSeq.toAsyncEnum

我的客户是这样的:

use http = GrpcChannel.ForAddress("http://localhost:10042")
let client = http.CreateGrpcService<ITimeService>()
async {
    for (min, sec) in client.SubscribeTupleAsync() |> AsyncSeq.ofAsyncEnum do
        printfn "%s, %s" min sec
} |> Async.RunSynchronously

合同是:

[<ServiceContract>]
type ITimeService =
    abstract member SubscribeTupleAsync : unit -> IAsyncEnumerable<string * string>

.proto 文件是:

syntax = "proto3";
package ProtobufCommon;
import "google/protobuf/empty.proto";

message Tuple_String_String {
   string Item1 = 1;
   string Item2 = 2;
}
service TimeService {
   rpc SubscribeTuple (.google.protobuf.Empty) returns (stream Tuple_String_String);
}

客户端输出为:

3, 26
3, 27
3, 28
3, 29
3, 30
3, 31
3, 32
3, 33
3, 34
3, 35
...