Sha256: a70db7071e40068eb5c828a1b28140352d862710c2cb0cbcdd95deed9bbbd718

Contents?: true

Size: 689 Bytes

Versions: 4

Compression:

Stored size: 689 Bytes

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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
karafka-2.0.17 lib/karafka/embedded.rb
karafka-2.0.16 lib/karafka/embedded.rb
karafka-2.0.15 lib/karafka/embedded.rb
karafka-2.0.14 lib/karafka/embedded.rb