class Labkit::Correlation::GRPC::ServerInterceptor

ServerInterceptor is a server-side GRPC interceptor for injecting GRPC calls with a correlation-id passed from a GRPC client to the GRPC Ruby Service

Public Instance Methods

bidi_streamer(requests: nil, call: nil, method: nil) { || ... } click to toggle source
# File lib/labkit/correlation/grpc/server_interceptor.rb, line 35
def bidi_streamer(requests: nil, call: nil, method: nil)
  wrap_with_correlation_id(call) do
    yield
  end
end
client_streamer(call: nil, method: nil) { || ... } click to toggle source
# File lib/labkit/correlation/grpc/server_interceptor.rb, line 23
def client_streamer(call: nil, method: nil)
  wrap_with_correlation_id(call) do
    yield
  end
end
request_response(request: nil, call: nil, method: nil) { || ... } click to toggle source
# File lib/labkit/correlation/grpc/server_interceptor.rb, line 17
def request_response(request: nil, call: nil, method: nil)
  wrap_with_correlation_id(call) do
    yield
  end
end
server_streamer(request: nil, call: nil, method: nil) { || ... } click to toggle source
# File lib/labkit/correlation/grpc/server_interceptor.rb, line 29
def server_streamer(request: nil, call: nil, method: nil)
  wrap_with_correlation_id(call) do
    yield
  end
end

Private Instance Methods

wrap_with_correlation_id(call, &block) click to toggle source
# File lib/labkit/correlation/grpc/server_interceptor.rb, line 43
def wrap_with_correlation_id(call, &block)
  correlation_id = call.metadata[CORRELATION_METADATA_KEY]
  correlation_id ||= Labkit::Correlation::CorrelationId.current_or_new_id

  Labkit::Correlation::CorrelationId.use_id(correlation_id, &block)
end