class GRPC::InterceptionContext

Represents the context in which an interceptor runs. Used to provide an injectable mechanism for handling interception. This is an EXPERIMENTAL API.

Public Class Methods

new(interceptors = []) click to toggle source

@param interceptors [Array<GRPC::Interceptor>]

# File src/ruby/lib/grpc/generic/interceptors.rb, line 158
def initialize(interceptors = [])
  @interceptors = interceptors.dup
end

Public Instance Methods

intercept!(type, args = {}) { || ... } click to toggle source

Intercept the call and fire out to interceptors in a FIFO execution. This is an EXPERIMENTAL API.

@param [Symbol] type The request type @param [Hash] args The arguments for the call

# File src/ruby/lib/grpc/generic/interceptors.rb, line 169
def intercept!(type, args = {})
  return yield if @interceptors.none?

  i = @interceptors.pop
  return yield unless i

  i.send(type, **args) do
    if @interceptors.any?
      intercept!(type, args) do
        yield
      end
    else
      yield
    end
  end
end