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(message) ⇒ Object



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

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

#distribute(message) ⇒ Object



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

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

#scatter_all(message, key) ⇒ Object



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

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