Class: Karafka::Routing::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/routing/proxy.rb

Overview

Proxy is used as a translation layer in between the DSL and raw topic and consumer group objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, defaults = ->(_) {}, &block) ⇒ Proxy

Returns a new instance of Proxy.

Parameters:

  • target (Object)

    target object to which we proxy any DSL call

  • defaults (Proc) (defaults to: ->(_) {})

    defaults for target that should be applicable after the proper proxy context (if needed)

  • block (Proc)

    block that we want to evaluate in the proxy context



14
15
16
17
18
# File 'lib/karafka/routing/proxy.rb', line 14

def initialize(target, defaults = ->(_) {}, &block)
  @target = target
  instance_eval(&block)
  instance_eval(&defaults)
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target.



8
9
10
# File 'lib/karafka/routing/proxy.rb', line 8

def target
  @target
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Tells whether or not a given element exists on the target

Parameters:

  • method_name (Symbol)

    name of the missing method

  • include_private (Boolean) (defaults to: false)

    should we include private in the check as well

Returns:

  • (Boolean)


40
41
42
43
44
# File 'lib/karafka/routing/proxy.rb', line 40

def respond_to_missing?(method_name, include_private = false)
  @target.respond_to?(:"#{method_name}=", include_private) ||
    @target.respond_to?(method_name, include_private) ||
    super
end