Module: Karafka::Pro::Routing::Features::ActiveJob::Builder

Defined in:
lib/karafka/pro/routing/features/active_job/builder.rb

Overview

Pro ActiveJob builder expansions

Instance Method Summary collapse

Instance Method Details

#active_job_pattern(regexp_or_name, regexp = nil, &block) ⇒ Object

This method simplifies routes definition for ActiveJob patterns / queues by auto-injecting the consumer class and other things needed

Parameters:

  • regexp_or_name (String, Symbol, Regexp)

    pattern name or regexp to use auto-generated regexp names

  • regexp (Regexp, nil) (defaults to: nil)

    activejob regexp pattern or nil when regexp is provided as the first argument

  • block (Proc)

    block that we can use for some extra configuration



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/karafka/pro/routing/features/active_job/builder.rb', line 29

def active_job_pattern(regexp_or_name, regexp = nil, &block)
  pattern(regexp_or_name, regexp) do
    consumer App.config.internal.active_job.consumer_class
    active_job true
    manual_offset_management true

    next unless block

    instance_eval(&block)
  end
end