Sha256: 3c2f2410855fdec0ea32ff431191798f4644c93fb70b61a063cac4653c83c25e
Contents?: true
Size: 1.36 KB
Versions: 28
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true # Disable the UnusedMethodArgument linter, since we need to declare the kwargs # in the methods, but we don't actually use them. require "grpc" require "singleton" module Labkit module Correlation module GRPC # ClientInterceptor is used to inject the correlation_id into the metadata # or a GRPC call for onward propagation to the server class ClientInterceptor < ::GRPC::ClientInterceptor include Labkit::Correlation::GRPC::GRPCCommon include Singleton def request_response(request:, call:, method:, metadata:) inject_correlation_id_into_metadata(metadata) yield end def client_streamer(requests:, call:, method:, metadata:) inject_correlation_id_into_metadata(metadata) yield end def server_streamer(request:, call:, method:, metadata:) inject_correlation_id_into_metadata(metadata) yield end def bidi_streamer(requests:, call:, method:, metadata:) inject_correlation_id_into_metadata(metadata) yield end private def inject_correlation_id_into_metadata(metadata, &block) metadata[CORRELATION_METADATA_KEY] = Labkit::Correlation::CorrelationId.current_id if Labkit::Correlation::CorrelationId.current_id end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems