Class: Karafka::Process
- Inherits:
-
Object
- Object
- Karafka::Process
- Includes:
- Singleton
- Defined in:
- lib/karafka/process.rb
Overview
Note:
There might be only one process - this class is a singleton
Class used to catch signals from ruby Signal class in order to manage Karafka stop
Constant Summary collapse
- HANDLED_SIGNALS =
Signal types that we handle
%i[ SIGINT SIGQUIT SIGTERM ].freeze
Instance Method Summary collapse
-
#initialize ⇒ Process
constructor
Creates an instance of process and creates empty hash for callbacks.
-
#supervise ⇒ Object
Method catches all HANDLED_SIGNALS and performs appropriate callbacks (if defined).
Constructor Details
#initialize ⇒ Process
Creates an instance of process and creates empty hash for callbacks
31 32 33 |
# File 'lib/karafka/process.rb', line 31 def initialize @callbacks = Hash.new { |hsh, key| hsh[key] = [] } end |
Instance Method Details
#supervise ⇒ Object
Note:
If there are no callbacks, this method will just ignore a given signal that was sent
Method catches all HANDLED_SIGNALS and performs appropriate callbacks (if defined)
37 38 39 |
# File 'lib/karafka/process.rb', line 37 def supervise HANDLED_SIGNALS.each { |signal| trap_signal(signal) } end |