Module: Karafka::Pro::Routing::Features::Filtering::Topic

Defined in:
lib/karafka/pro/routing/features/filtering/topic.rb

Overview

Filtering feature topic extensions

Instance Method Summary collapse

Instance Method Details

#filter(factory = nil) ⇒ Object

Parameters:

  • factory (#call, nil) (defaults to: nil)

    Callable that can produce new filters instances per assigned topic partition. nil as default so this feature is disabled



23
24
25
26
27
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 23

def filter(factory = nil)
  @filtering ||= Config.new(factories: [])
  @filtering.factories << factory if factory
  @filtering
end

#filtering(*args) ⇒ Filtering::Config

Returns alias to match the naming API for features.

Parameters:

  • args (Array)

    Anything ‘#filter` accepts

Returns:



31
32
33
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 31

def filtering(*args)
  filter(*args)
end

#filtering?Boolean

Returns is a given job throttled.

Returns:

  • (Boolean)

    is a given job throttled



36
37
38
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 36

def filtering?
  filtering.active?
end

#to_hHash

Returns topic with all its native configuration options plus throttling.

Returns:

  • (Hash)

    topic with all its native configuration options plus throttling



41
42
43
44
45
# File 'lib/karafka/pro/routing/features/filtering/topic.rb', line 41

def to_h
  super.merge(
    filtering: filtering.to_h
  ).freeze
end