class Gruf::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/gruf/interceptors/client_interceptor.rb, line 105 def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil, &block) rc = Gruf::Outbound::RequestContext.new( type: :bidi_streamer, requests: requests, call: call, method: method, metadata: metadata ) call(request_context: rc, &block) end
Handles interception of outbound calls. Implement this in your derivative interceptor implementation.
@param [Gruf::Outbound::RequestContext] request_context The context of the outbound request @return [Object] This method must return the response from the yielded block
# File lib/gruf/interceptors/client_interceptor.rb, line 32 def call(request_context:) logger.debug "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/gruf/interceptors/client_interceptor.rb, line 66 def client_streamer(requests: nil, call: nil, method: nil, metadata: nil, &block) rc = Gruf::Outbound::RequestContext.new( type: :client_streamer, requests: requests, call: call, method: method, metadata: metadata ) call(request_context: rc, &block) 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/gruf/interceptors/client_interceptor.rb, line 46 def request_response(request: nil, call: nil, method: nil, metadata: nil, &block) rc = Gruf::Outbound::RequestContext.new( type: :request_response, requests: [request], call: call, method: method, metadata: metadata ) call(request_context: rc, &block) 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/gruf/interceptors/client_interceptor.rb, line 86 def server_streamer(request: nil, call: nil, method: nil, metadata: nil, &block) rc = Gruf::Outbound::RequestContext.new( type: :server_streamer, requests: [request], call: call, method: method, metadata: metadata ) call(request_context: rc, &block) end