Class: Droonga::DistributorPlugin

Inherits:
Plugin
  • Object
show all
Extended by:
PluginRegisterable
Defined in:
lib/droonga/distributor_plugin.rb

Instance Method Summary collapse

Methods included from PluginRegisterable

command, extended, inherited, method_name, processable?, repository

Methods inherited from Plugin

#process, #processable?, #shutdown, #start

Constructor Details

#initialize(distributor) ⇒ DistributorPlugin

Returns a new instance of DistributorPlugin.



24
25
26
27
# File 'lib/droonga/distributor_plugin.rb', line 24

def initialize(distributor)
  super()
  @distributor = distributor
end

Instance Method Details

#broadcast_all(envelope) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/droonga/distributor_plugin.rb', line 47

def broadcast_all(envelope)
  distirubte_message = [{
    "command"=> envelope["type"],
    "dataset"=> envelope["dataset"],
    "body"=> envelope["body"],
    "type"=> "broadcast",
    "replica"=> "all",
    "post"=> true
  }]
  post(distirubte_message)
end

#post(message) ⇒ Object

TODO: consider better name



30
31
32
# File 'lib/droonga/distributor_plugin.rb', line 30

def post(message)
  @distributor.post(message)
end

#scatter_all(envelope, key) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/droonga/distributor_plugin.rb', line 34

def scatter_all(envelope, key)
  message = [{
    "command"=> envelope["type"],
    "dataset"=> envelope["dataset"],
    "body"=> envelope["body"],
    "key"=> key,
    "type"=> "scatter",
    "replica"=> "all",
    "post"=> true
  }]
  post(message)
end