Sha256: 4dcc066f6c66e20343e18083a702dd282c9558376a374bc850dc90bba05923b7

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 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 { Karafka::Server.start }
      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

15 entries across 15 versions & 1 rubygems

Version Path
karafka-2.0.33 lib/karafka/embedded.rb
karafka-2.0.32 lib/karafka/embedded.rb
karafka-2.0.31 lib/karafka/embedded.rb
karafka-2.0.30 lib/karafka/embedded.rb
karafka-2.0.29 lib/karafka/embedded.rb
karafka-2.0.28 lib/karafka/embedded.rb
karafka-2.0.27 lib/karafka/embedded.rb
karafka-2.0.26 lib/karafka/embedded.rb
karafka-2.0.24 lib/karafka/embedded.rb
karafka-2.0.23 lib/karafka/embedded.rb
karafka-2.0.22 lib/karafka/embedded.rb
karafka-2.0.21 lib/karafka/embedded.rb
karafka-2.0.20 lib/karafka/embedded.rb
karafka-2.0.19 lib/karafka/embedded.rb
karafka-2.0.18 lib/karafka/embedded.rb