Class: TestServerInterceptor

Inherits:
GRPC::ServerInterceptor show all
Defined in:
src/ruby/spec/support/services.rb

Overview

For testing server interceptors

Instance Method Summary collapse

Methods inherited from GRPC::Interceptor

#initialize

Constructor Details

This class inherits a constructor from GRPC::Interceptor

Instance Method Details

#bidi_streamer(requests:, call:, method:) ⇒ Object



113
114
115
116
117
118
119
120
121
# File 'src/ruby/spec/support/services.rb', line 113

def bidi_streamer(requests:, call:, method:)
  requests.each do |r|
    GRPC.logger.info("Bidi request: #{r}")
  end
  GRPC.logger.info("Received bidi streamer call at method #{method} with requests" \
    " #{requests} for call #{call}")
  call.[:interc] = 'from_bidi_streamer'
  yield
end

#client_streamer(call:, method:) ⇒ Object



95
96
97
98
99
100
101
102
103
104
# File 'src/ruby/spec/support/services.rb', line 95

def client_streamer(call:, method:)
  call.[:interc] = 'from_client_streamer'
  call.each_remote_read.each do |r|
    GRPC.logger.info("In interceptor: #{r}")
  end
  GRPC.logger.info(
    "Received client streamer call at method #{method} for call #{call}"
  )
  yield
end

#request_response(request:, call:, method:) ⇒ Object



87
88
89
90
91
92
93
# File 'src/ruby/spec/support/services.rb', line 87

def request_response(request:, call:, method:)
  GRPC.logger.info("Received request/response call at method #{method}" \
    " with request #{request} for call #{call}")
  call.[:interc] = 'from_request_response'
  GRPC.logger.info("[GRPC::Ok] (#{method.owner.name}.#{method.name})")
  yield
end

#server_streamer(request:, call:, method:) ⇒ Object



106
107
108
109
110
111
# File 'src/ruby/spec/support/services.rb', line 106

def server_streamer(request:, call:, method:)
  GRPC.logger.info("Received server streamer call at method #{method} with request" \
    " #{request} for call #{call}")
  call.[:interc] = 'from_server_streamer'
  yield
end