Sha256: ad2961e26d33e5c8a5ec6ad4c51be5e69d5d9c76d01e729fcbc4880a04570f91

Contents?: true

Size: 1.1 KB

Versions: 47

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Karafka
  # Allows to start and stop Karafka as part of a different process
  module Embedded
    class << self
      # Starts Karafka without supervision and without ownership of signals in a background thread
      # so it won't interrupt other things running
      def start
        Thread.new do
          Karafka::Process.tags.add(:execution_mode, 'embedded')
          Karafka::Server.start
        end
      end

      # Stops Karafka upon any event
      #
      # @note This method is blocking because we want to wait until Karafka is stopped with final
      #   process shutdown
      def stop
        # Stop needs to be blocking to wait for all the things to finalize
        Karafka::Server.stop
      end

      # Quiets Karafka upon any event
      #
      # @note This method is not blocking and will not wait for Karafka to fully quiet.
      # It will trigger the quiet procedure but won't wait.
      #
      # @note Please keep in mind you need to `#stop` to actually stop the server anyhow.
      def quiet
        Karafka::Server.quiet
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
karafka-2.3.4 lib/karafka/embedded.rb
karafka-2.3.3 lib/karafka/embedded.rb
karafka-2.3.2 lib/karafka/embedded.rb
karafka-2.3.1 lib/karafka/embedded.rb
karafka-2.3.0 lib/karafka/embedded.rb
karafka-2.3.0.rc1 lib/karafka/embedded.rb
karafka-2.3.0.alpha2 lib/karafka/embedded.rb
karafka-2.3.0.alpha1 lib/karafka/embedded.rb
karafka-2.2.14 lib/karafka/embedded.rb
karafka-2.2.13 lib/karafka/embedded.rb
karafka-2.2.12 lib/karafka/embedded.rb
karafka-2.2.11 lib/karafka/embedded.rb
karafka-2.2.10 lib/karafka/embedded.rb
karafka-2.2.9 lib/karafka/embedded.rb
karafka-2.2.8 lib/karafka/embedded.rb
karafka-2.2.8.beta1 lib/karafka/embedded.rb
karafka-2.2.7 lib/karafka/embedded.rb
karafka-2.2.6 lib/karafka/embedded.rb
karafka-2.2.5 lib/karafka/embedded.rb
karafka-2.2.4 lib/karafka/embedded.rb