class Yrpc::Interceptors::ClientInterceptor
Intercepts outbound client requests to provide a unified interface and request context
Public Instance Methods
Call the interceptor from the bidi_streamer
call
@param [Enumerable] requests An enumerable of requests being sent @param [GRPC::ActiveCall] call The GRPC ActiveCall object @param [Method] method The method being called @param [Hash] metadata A hash of outgoing metadata
# File lib/yrpc/interceptors/client_interceptor.rb, line 90 def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil) rc = Yrpc::Outbound::RequestContext.new(type: :bidi_streamer, requests: requests, call: call, method: method, metadata: metadata) call(request_context: rc) yield end
Handles interception of outbound calls. Implement this in your derivative interceptor implementation.
@param [Yrpc::Outbound::RequestContext] request_context The context of the outbound request @return [Object] This method must return the response from the yielded block
# File lib/yrpc/interceptors/client_interceptor.rb, line 30 def call(request_context:) Yrpc.logger "Logging client interceptor for request: #{request_context.method}" yield end
Call the interceptor from the client_streamer
call
@param [Enumerable] requests An enumerable of requests being sent @param [GRPC::ActiveCall] call The GRPC ActiveCall object @param [Method] method The method being called @param [Hash] metadata A hash of outgoing metadata @return [Object] The response message
# File lib/yrpc/interceptors/client_interceptor.rb, line 60 def client_streamer(requests: nil, call: nil, method: nil, metadata: nil) rc = Yrpc::Outbound::RequestContext.new(type: :client_streamer, requests: requests, call: call, method: method, metadata: metadata) call(request_context: rc) matadata= metadata.merge!(rc.metadata) yield end
Call the interceptor from the request_response
call
@param [Object] request The request being sent @param [GRPC::ActiveCall] call The GRPC ActiveCall object @param [Method] method The method being called @param [Hash] metadata A hash of outgoing metadata @return [Object] The response message
# File lib/yrpc/interceptors/client_interceptor.rb, line 44 def request_response(request: nil, call: nil, method: nil, metadata: nil) rc = Yrpc::Outbound::RequestContext.new(type: :request_response, requests: [request], call: call, method: method, metadata: metadata) call(request_context: rc) matadata= metadata.merge!(rc.metadata) yield end
Call the interceptor from the server_streamer
call
@param [Object] request The request being sent @param [GRPC::ActiveCall] call The GRPC ActiveCall object @param [Method] method The method being called @param [Hash] metadata A hash of outgoing metadata @return [Object] The response message
# File lib/yrpc/interceptors/client_interceptor.rb, line 76 def server_streamer(request: nil, call: nil, method: nil, metadata: nil) rc = Yrpc::Outbound::RequestContext.new(type: :server_streamer, requests: [request], call: call, method: method, metadata: metadata) call(request_context: rc) yield end