Class: SlowService

Inherits:
Object
  • Object
show all
Includes:
GRPC::GenericService
Defined in:
src/ruby/spec/generic/rpc_server_spec.rb

Overview

A slow test service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GRPC::GenericService

included, underscore

Constructor Details

#initialize(_default_var = 'ignored') ⇒ SlowService

Returns a new instance of SlowService.



67
68
69
70
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 67

def initialize(_default_var = 'ignored')
  @delay = 0.25
  @received_md = []
end

Instance Attribute Details

#delayObject (readonly)

Returns the value of attribute delay.



65
66
67
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 65

def delay
  @delay
end

#received_mdObject (readonly)

Returns the value of attribute received_md.



65
66
67
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 65

def received_md
  @received_md
end

Instance Method Details

#a_server_streaming_rpc(_, call) ⇒ Object



79
80
81
82
83
84
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 79

def a_server_streaming_rpc(_, call)
  GRPC.logger.info("starting a slow #{@delay} server streaming rpc")
  sleep @delay
  @received_md << call. unless call..nil?
  [EchoMsg.new, EchoMsg.new]
end

#an_rpc(req, call) ⇒ Object



72
73
74
75
76
77
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 72

def an_rpc(req, call)
  GRPC.logger.info("starting a slow #{@delay} rpc")
  sleep @delay
  @received_md << call. unless call..nil?
  req  # send back the req as the response
end