Class: SynchronizedCancellationService

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

Overview

A test service that allows a synchronized RPC cancellation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GRPC::GenericService

included, underscore

Constructor Details

#initialize(notify_request_received, wait_until_rpc_cancelled) ⇒ SynchronizedCancellationService

notify_request_received and wait_until_rpc_cancelled are callbacks to synchronously allow the client to proceed with cancellation (after the unary request has been received), and to synchronously wait until the client has cancelled the current RPC.



100
101
102
103
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 100

def initialize(notify_request_received, wait_until_rpc_cancelled)
  @notify_request_received = notify_request_received
  @wait_until_rpc_cancelled = wait_until_rpc_cancelled
end

Instance Attribute Details

#delayObject (readonly)

Returns the value of attribute delay.



93
94
95
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 93

def delay
  @delay
end

#received_mdObject (readonly)

Returns the value of attribute received_md.



93
94
95
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 93

def received_md
  @received_md
end

Instance Method Details

#an_rpc(req, _call) ⇒ Object



105
106
107
108
109
110
# File 'src/ruby/spec/generic/rpc_server_spec.rb', line 105

def an_rpc(req, _call)
  GRPC.logger.info('starting a synchronusly cancelled rpc')
  @notify_request_received.call(req)
  @wait_until_rpc_cancelled.call
  req  # send back the req as the response
end