Class: Griffin::Interceptors::Server::PayloadInterceptor

Inherits:
GRPC::ServerInterceptor
  • Object
show all
Defined in:
lib/griffin/interceptors/server/payload_interceptor.rb

Direct Known Subclasses

FilteredPayloadInterceptor

Instance Method Summary collapse

Instance Method Details

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



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/griffin/interceptors/server/payload_interceptor.rb', line 9

def request_response(request: nil, call: nil, **)
  logs = {}

  if call.['x-request-id']
    logs['grpc.x_request_id'] = call.['x-request-id']
  end

  GRPC.logger.info(logs.merge('grpc.request.content' => extract_content(request)))

  yield.tap do |resp|
    logs['grpc.response.content'] = extract_content(resp)
    GRPC.logger.info(logs)
  end
end

#server_streamer(call: nil) {|Griffin::Interceptors::Server::PayloadStreamer.new(call, GRPC.logger, logs)| ... } ⇒ Object Also known as: client_streamer, bidi_streamer

Yields:



24
25
26
27
28
29
30
31
32
# File 'lib/griffin/interceptors/server/payload_interceptor.rb', line 24

def server_streamer(call: nil, **)
  logs = {}

  if call.['x-request-id']
    logs['grpc.x_request_id'] = call.['x-request-id']
  end

  yield(Griffin::Interceptors::Server::PayloadStreamer.new(call, GRPC.logger, logs))
end