Logo
Section 1 / 3

双向流式 RPC

了解 gRPC 中的双向流式 RPC,以及如何实现它。

检查点

双向流式 RPC

了解 gRPC 中的双向流式 RPC,以及如何实现它。

...
双向流 API

.proto 文件中的双向流 API

1rpc BidirectionalStreamingExample(stream Request) returns (stream Response) {}

双向 getFileAttributes RPC

1service FTPService { 2 3 // 删除服务器目标目录中的文件 4 rpc deleteFile (MetaData) returns (Result) {}; 5 6 // 将文件添加到服务器的目标目录中。 7 rpc addFile(stream AddFileRequest) returns(Result){}; 8 9 // 从服务器的目标目录读取文件。 10 rpc readFile(MetaData) returns (stream ReadFileResult); 11 12 // 返回服务器上请求文件的文件属性 13 rpc getFileAttributes(stream MetaData) returns (stream FileAttributesResult); 14}

FileAttributesResult 消息

1message FileAttributesResult{ 2 oneof request { 3 string message = 1; 4 FileAttributes fileAttributes = 2; 5 } 6} 7 8message FileAttributes{ 9 string name = 1; 10 int64 size = 2; 11 string creationTime = 3; 12 string modificationTime = 4; 13}

No configuration found for ID: 734afe6bcfc3f72c1f2c9e3c33a6ed5bebfbee5a8333fa07e018a1fb126ea334

1.

What is the difference between client streaming and bidirectional streaming RPC?

0/500
2.

How are client streaming and bidirectional streaming RPC same?

0/500

客户端流 vs. 双向流 RPC

1.

How does using a blocking stub affect the implementation of a bidirectional streaming RPC?

0/500

值得思考的问题

Quiz

单选题

我们可以为双向流式 RPC 创建哪些桩函数?

1 / 2

Server Streaming RPC

服务器端双向流式 RPC 实现