Class: Norikra::Listener::Loopback

Inherits:
Base
  • Object
show all
Defined in:
lib/norikra/listener.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_ASYNC_INTERVAL

Instance Attribute Summary collapse

Attributes inherited from Base

#events_statistics

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#apply_type_convert_to_events, #background, #push, #shutdown, #start, #type_convert, #update

Constructor Details

#initialize(argument, query_name, query_group) ⇒ Loopback

Returns a new instance of Loopback.



224
225
226
227
228
229
# File 'lib/norikra/listener.rb', line 224

def initialize(argument, query_name, query_group)
  super
  if @argument.nil? || @argument.empty?
    raise Norikra::ClientError, "LOOPBACK target name not specified"
  end
end

Instance Attribute Details

#engine=(value) ⇒ Object (writeonly)

Sets the attribute engine

Parameters:

  • value

    the value to set the attribute engine to.



205
206
207
# File 'lib/norikra/listener.rb', line 205

def engine=(value)
  @engine = value
end

Class Method Details

.labelObject



207
208
209
# File 'lib/norikra/listener.rb', line 207

def self.label
  "LOOPBACK"
end

.target(query_group) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/norikra/listener.rb', line 211

def self.target(query_group)
  if query_group
    opts = Norikra::Listener.parse(query_group)
    if opts && opts[:name] == label()
      opts[:argument]
    else
      nil
    end
  else
    nil
  end
end

Instance Method Details

#process_sync(news, olds) ⇒ Object



231
232
233
234
235
236
237
238
# File 'lib/norikra/listener.rb', line 231

def process_sync(news, olds)
  # We does NOT convert 'container.$0' into container['field'].
  # Use escaped names like 'container__0'. That is NOT so confused.
  trace("loopback event"){ { query: @query_name, group: @query_group, event: news } }
  if news.respond_to?(:each)
    @engine.send(@argument, news)
  end
end