Sha256: 50bd007dbb2d293fc6f28debf9749e1fb93292654518d2fd82d25c040d445fa4

Contents?: true

Size: 1.47 KB

Versions: 27

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Karafka
  # App class
  class App
    extend Setup::Dsl

    class << self
      # Sets up all the internal components and bootstrap whole app
      # We need to know details about consumers in order to setup components,
      # that's why we don't setup them after std setup is done
      # @raise [Karafka::Errors::InvalidConfigurationError] raised when configuration
      #   doesn't match with the config contract
      def boot!
        initialize!
        Setup::Config.validate!
        Setup::Config.setup_components
        initialized!
      end

      # @return [Karafka::Routing::Builder] consumers builder instance
      def consumer_groups
        config.internal.routing_builder
      end

      # Triggers reload of all cached Karafka app components, so we can use in-process
      # in-development hot code reloading without Karafka process restart
      def reload
        Karafka::Persistence::Consumers.clear
        Karafka::Persistence::Topics.clear
        config.internal.routing_builder.reload
      end

      Status.instance_methods(false).each do |delegated|
        define_method(delegated) do
          App.config.internal.status.send(delegated)
        end
      end

      # Methods that should be delegated to Karafka module
      %i[
        root
        env
        logger
        monitor
      ].each do |delegated|
        define_method(delegated) do
          Karafka.send(delegated)
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
karafka-1.4.15 lib/karafka/app.rb
karafka-1.4.14 lib/karafka/app.rb
karafka-1.4.13 lib/karafka/app.rb
karafka-1.4.12 lib/karafka/app.rb
karafka-1.4.11 lib/karafka/app.rb
karafka-1.4.10 lib/karafka/app.rb
karafka-1.4.9 lib/karafka/app.rb
karafka-1.4.8 lib/karafka/app.rb
karafka-1.4.7 lib/karafka/app.rb
karafka-1.4.6 lib/karafka/app.rb
karafka-1.4.5 lib/karafka/app.rb
karafka-1.4.4 lib/karafka/app.rb
karafka-1.4.3 lib/karafka/app.rb
karafka-1.4.2 lib/karafka/app.rb
karafka-1.4.1 lib/karafka/app.rb
karafka-1.4.0 lib/karafka/app.rb
karafka-1.4.0.rc2 lib/karafka/app.rb
karafka-1.4.0.rc1 lib/karafka/app.rb
karafka-1.3.7 lib/karafka/app.rb
karafka-1.3.6 lib/karafka/app.rb