class GrpcKit::Interceptors::Server::Streaming

Public Class Methods

new(interceptors) click to toggle source

@param interceptors [Array<GrpcKit::Grpc::ServerInterceptor>]

# File lib/grpc_kit/interceptors.rb, line 39
def initialize(interceptors)
  @registry = GrpcKit::InterceptorRegistry.new(interceptors)
end

Public Instance Methods

intercept(call, &block) click to toggle source
# File lib/grpc_kit/interceptors.rb, line 43
def intercept(call, &block)
  do_intercept(@registry.build, call, &block)
end

Private Instance Methods

do_intercept(interceptors, call) { |call| ... } click to toggle source
# File lib/grpc_kit/interceptors.rb, line 49
def do_intercept(interceptors, call)
  if interceptors.empty?
    return yield(call)
  end

  interceptor = interceptors.pop
  invoke(interceptor, call) do |inter_call|
    do_intercept(interceptors, inter_call) do |c|
      yield(c)
    end
  end
end