Class: FullDuplexEnumerator
- Inherits:
-
Object
- Object
- FullDuplexEnumerator
- Includes:
- Grpc::Testing, Grpc::Testing::PayloadType
- Defined in:
- src/ruby/pb/test/server.rb
Overview
A FullDuplexEnumerator passes requests to a block and yields generated responses
Constant Summary
Constants included from Grpc::Testing
Grpc::Testing::BoolValue, Grpc::Testing::EchoStatus, Grpc::Testing::Empty, Grpc::Testing::EmptyMessage, Grpc::Testing::GaugeRequest, Grpc::Testing::GaugeResponse, Grpc::Testing::Payload, Grpc::Testing::PayloadType, Grpc::Testing::ReconnectInfo, Grpc::Testing::ReconnectParams, Grpc::Testing::ResponseParameters, Grpc::Testing::SimpleRequest, Grpc::Testing::SimpleResponse, Grpc::Testing::StreamingInputCallRequest, Grpc::Testing::StreamingInputCallResponse, Grpc::Testing::StreamingOutputCallRequest, Grpc::Testing::StreamingOutputCallResponse
Instance Method Summary collapse
- #each_item ⇒ Object
-
#initialize(requests) ⇒ FullDuplexEnumerator
constructor
A new instance of FullDuplexEnumerator.
Constructor Details
#initialize(requests) ⇒ FullDuplexEnumerator
Returns a new instance of FullDuplexEnumerator.
158 159 160 |
# File 'src/ruby/pb/test/server.rb', line 158 def initialize(requests) @requests = requests end |
Instance Method Details
#each_item ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'src/ruby/pb/test/server.rb', line 161 def each_item return enum_for(:each_item) unless block_given? GRPC.logger.info('interop-server: started receiving') begin cls = StreamingOutputCallResponse @requests.each do |req| (req) req.response_parameters.each do |params| resp_size = params.size GRPC.logger.info("read a req, response size is #{resp_size}") yield cls.new(payload: Payload.new(type: req.response_type, body: nulls(resp_size))) end end GRPC.logger.info('interop-server: finished receiving') rescue StandardError => e GRPC.logger.info('interop-server: failed') GRPC.logger.warn(e) fail e end end |