Module: Nagare::Listener::ClassMethods

Defined in:
lib/nagare/listener.rb

Overview

Class methods that automatically get added to inheriting classes

Instance Method Summary collapse

Instance Method Details

#stream(name) ⇒ Object

Defines the name of the stream this listener listens to.

This method causes the listener to register itself with the listener pool, creating automatically a consumer group if none exists for the stream, and the stream itself if not initialized.

Defining a stream is required for every listener, failing to do so will cause the listener never to be invoked.

Parameters:

  • name (String)

    name of the stream the listener should listen to.



29
30
31
32
33
34
35
# File 'lib/nagare/listener.rb', line 29

def stream(name)
  class_variable_set(:@@stream_name, name)

  # Force consumer group creation
  Nagare::ListenerPool.listener_pool
  name
end

#stream_nameObject



37
38
39
# File 'lib/nagare/listener.rb', line 37

def stream_name
  class_variable_get(:@@stream_name)
end