Module: Karafka::Embedded

Defined in:
lib/karafka/embedded.rb

Overview

Allows to start and stop Karafka as part of a different process

Class Method Summary collapse

Class Method Details

.quietObject

Note:

This method is not blocking and will not wait for Karafka to fully quiet.

Note:

Please keep in mind you need to ‘#stop` to actually stop the server anyhow.

Quiets Karafka upon any event

It will trigger the quiet procedure but won’t wait.



31
32
33
# File 'lib/karafka/embedded.rb', line 31

def quiet
  Karafka::Server.quiet
end

.startObject

Starts Karafka without supervision and without ownership of signals in a background thread so it won’t interrupt other things running



9
10
11
12
13
14
# File 'lib/karafka/embedded.rb', line 9

def start
  Thread.new do
    Karafka::Process.tags.add(:execution_mode, 'embedded')
    Karafka::Server.start
  end
end

.stopObject

Note:

This method is blocking because we want to wait until Karafka is stopped with final process shutdown

Stops Karafka upon any event



20
21
22
23
# File 'lib/karafka/embedded.rb', line 20

def stop
  # Stop needs to be blocking to wait for all the things to finalize
  Karafka::Server.stop
end