Sha256: e5e241227f72fb5d7685c5def9f5cad2e92dbd2d0a06835b4483a52000d2de52

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Karafka
  # Additional callbacks that are used to trigger some things in given places during the
  # system lifecycle
  # @note Those callbacks aren't the same as consumer callbacks as they are not related to the
  #   lifecycle of particular messages fetches but rather to the internal flow process.
  #   They cannot be defined on a consumer callback level because for some of those,
  #   there aren't consumers in the memory yet and/or they aren't per consumer thread
  module Callbacks
    # Types of system callbacks that we have that are not related to consumers
    TYPES = %i[
      after_init
      before_fetch_loop
    ].freeze

    class << self
      TYPES.each do |callback_type|
        # Executes given callbacks set at a given moment with provided arguments
        define_method callback_type do |*args|
          Karafka::App
            .config
            .callbacks
            .send(callback_type)
            .each { |callback| callback.call(*args) }
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
karafka-1.2.13 lib/karafka/callbacks.rb
karafka-1.2.12 lib/karafka/callbacks.rb
karafka-1.2.11 lib/karafka/callbacks.rb
karafka-1.2.10 lib/karafka/callbacks.rb
karafka-1.2.9 lib/karafka/callbacks.rb
karafka-1.2.8 lib/karafka/callbacks.rb
karafka-1.2.7 lib/karafka/callbacks.rb
karafka-1.2.6 lib/karafka/callbacks.rb
karafka-1.2.5 lib/karafka/callbacks.rb
karafka-1.2.4 lib/karafka/callbacks.rb
karafka-1.2.3 lib/karafka/callbacks.rb
karafka-1.2.2 lib/karafka/callbacks.rb
karafka-1.2.1 lib/karafka/callbacks.rb
karafka-1.2.0 lib/karafka/callbacks.rb
karafka-1.2.0.beta4 lib/karafka/callbacks.rb
karafka-1.2.0.beta3 lib/karafka/callbacks.rb