Class: BlockingEnumerator

Inherits:
Object
  • Object
show all
Includes:
Grpc::Testing, Grpc::Testing::PayloadType
Defined in:
src/ruby/pb/test/client.rb

Constant Summary

Constants included from Grpc::Testing

Grpc::Testing::BoolValue, Grpc::Testing::ClientConfigureRequest, Grpc::Testing::ClientConfigureResponse, Grpc::Testing::EchoStatus, Grpc::Testing::Empty, Grpc::Testing::EmptyMessage, Grpc::Testing::GaugeRequest, Grpc::Testing::GaugeResponse, Grpc::Testing::GrpclbRouteType, Grpc::Testing::HookRequest, Grpc::Testing::HookResponse, Grpc::Testing::LoadBalancerAccumulatedStatsRequest, Grpc::Testing::LoadBalancerAccumulatedStatsResponse, Grpc::Testing::LoadBalancerStatsRequest, Grpc::Testing::LoadBalancerStatsResponse, Grpc::Testing::MemorySize, Grpc::Testing::Payload, Grpc::Testing::PayloadType, Grpc::Testing::ReconnectInfo, Grpc::Testing::ReconnectParams, Grpc::Testing::ResponseParameters, Grpc::Testing::SetReturnStatusRequest, Grpc::Testing::SimpleRequest, Grpc::Testing::SimpleResponse, Grpc::Testing::StreamingInputCallRequest, Grpc::Testing::StreamingInputCallResponse, Grpc::Testing::StreamingOutputCallRequest, Grpc::Testing::StreamingOutputCallResponse, Grpc::Testing::TestOrcaReport

Instance Method Summary collapse

Constructor Details

#initialize(req_size, sleep_time) ⇒ BlockingEnumerator

Returns a new instance of BlockingEnumerator.



221
222
223
224
# File 'src/ruby/pb/test/client.rb', line 221

def initialize(req_size, sleep_time)
  @req_size = req_size
  @sleep_time = sleep_time
end

Instance Method Details

#each_item {|req| ... } ⇒ Object

Yields:

  • (req)


226
227
228
229
230
231
232
233
# File 'src/ruby/pb/test/client.rb', line 226

def each_item
  return enum_for(:each_item) unless block_given?
  req_cls = StreamingOutputCallRequest
  req = req_cls.new(payload: Payload.new(body: nulls(@req_size)))
  yield req
  # Sleep until after the deadline should have passed
  sleep(@sleep_time)
end