Class: Droonga::Plugins::Watch::FeedHandler

Inherits:
Handler
  • Object
show all
Includes:
SchemaCreatable
Defined in:
lib/droonga/plugins/watch.rb

Instance Attribute Summary

Attributes inherited from Handler

#label, #loop, #messenger

Instance Method Summary collapse

Methods inherited from Handler

action, message

Methods included from Droonga::Pluggable

#find_sub_classes, #options

Constructor Details

#initialize(*args) ⇒ FeedHandler

Returns a new instance of FeedHandler.



127
128
129
130
# File 'lib/droonga/plugins/watch.rb', line 127

def initialize(*args)
  super
  ensure_schema_created # TODO: REMOVE ME
end

Instance Method Details

#handle(message) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/droonga/plugins/watch.rb', line 132

def handle(message)
  request = message.request
  watcher = Watcher.new(@context)
  watcher.feed(:targets => request["targets"]) do |route, subscribers|
    published_message = {
      "to"   => subscribers,
      "body" => request,
    }
    published_message = message.raw.merge(published_message)
    messenger.forward(published_message,
                      "to" => route, "type" => "watch.publish")
  end
  nil
end