Module: Fleck::Core::Consumer::Base::InstanceMethods

Defined in:
lib/fleck/core/consumer/base.rb

Overview

Defines instance methods to import when ‘Autostart` module is imported.

Instance Method Summary collapse

Instance Method Details

#autostart?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/fleck/core/consumer/base.rb', line 86

def autostart?
  configs[:autostart].nil? || configs[:autostart]
end

#startObject



90
91
92
93
94
95
# File 'lib/fleck/core/consumer/base.rb', line 90

def start
  logger.info "Launching #{self.class.to_s.color(:yellow)} consumer ..."
  connect!
  create_channel!
  subscribe!
end

#terminateObject



97
98
99
100
101
102
103
104
105
106
# File 'lib/fleck/core/consumer/base.rb', line 97

def terminate
  pause

  return if channel.nil? || channel.closed?

  channel.close

  logger.info 'Consumer successfully terminated.'
  self.class.on_terminate(self)
end